将 github 项目作为库导入到现有项目中 [英] Importing github projects as library to existing project

查看:48
本文介绍了将 github 项目作为库导入到现有项目中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我习惯于将库作为 .jar 文件导入,但我不知道如何使用来自 github 的项目,如下所示:https://github.com/jfeinstein10/SlidingMenu/

I am used to importing library as .jar file but I don't know how to use the projects from github like this: https://github.com/jfeinstein10/SlidingMenu/

我想在我现有的项目中使用它.我尝试在依赖项中包含项目文件,但它给了我一些错误

I want to use it in my existing project. I tried including the project file in the dependencies but it's giving me some errors

推荐答案

我已经解释过了 在这篇文章中 如何在 android studio 中使用项目库.但我知道,尤其是一开始,在您了解 AS-Projects 的结构之前,这并不容易.所以这里对您的问题进行解释:

I already explained in this post how to use a project library in android studio. But I know especially at the beginning it's not that easy until you understand the structur of AS-Projects. So here an explanation for your issue:

我通过像这样配置我的项目的 gradle 文件来将项目库添加​​到我的项目中:

I'm adding project libraries to my projects by configuring the gradle files of my project like this:

  • 在项目根目录中创建一个名为libs"的文件夹
  • 将 git 上 SlidingMenu 项目的完整文件夹library"复制到libs"中
  • 重命名您刚刚复制到的文件夹library",例如SlidingMenuLibrary"(只是为了避免混淆)
  • 现在使用以下命令将此库添加到您的 settings.gradle 中:

include ':libs:SlidingMenuLibrary'

  • 转到您的 AppProject 的 build.gradle 文件,并将以下行添加到您的依赖项":

  • go to your build.gradle file of your AppProject and add the following line to your 'dependencies':

    compile project(':libs:SlidingMenuLibrary')
    

  • 至少你必须同步你的 gradle 文件:Tools -> Android -> Sync Project with Gradle Files

  • at least you have to sync your gradle files: Tools -> Android -> Sync Project with Gradle Files

    请试试这个.如果出现错误,请发布日志文件.

    Please try this. If you get errors please post the log file.

    这篇关于将 github 项目作为库导入到现有项目中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

  • 查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆