简体   繁体   English

如何在一个Android项目中管理多个外部库?(Eclipse,Git,ADT)

[英]How do you manage multiple external libraries in an Android project?(Eclipse,Git,ADT)

The problem basically is if you have multiple developers working on a project and the project references multiple external libraries then it becomes hard to keep track of library versions and face issues related to it and the setup time increases every-time you import the project on a new machine. 基本上,问题是,如果您有多个开发人员在一个项目上工作,并且该项目引用了多个外部库,那么将很难跟踪库的版本并面临与之相关的问题,并且每次在计算机上导入项目时,安装时间都会增加。新机器。 Technologies used(eclipse,ADT,GIT) 使用的技术(eclipse,ADT,GIT)

Tried a bunch of options-build mgmt tools,repo managers and the likes. 尝试了一堆选项-构建mgmt工具,回购管理器等。 Heres whats worked for me. 这对我有用。 This solution is targeted for ppl who are not familiar with build management systems. 该解决方案面向不熟悉构建管理系统的ppl。 High level: Store all the libraries in a separate GIT repo that's centrally hosted(say:bitbucket). 高级:将所有库存储在单独的GIT仓库中,该仓库由中央托管(例如:bitbucket)。 In your android project add the above repo as a sub-module. 在您的android项目中,将上述存储库添加为子模块。

Now to get your project working you just have to import all the projects in your submodule in eclipse and in the project properties under Android point the project to these libraries. 现在,要使您的项目正常工作,您只需要将子模块中的所有项目导入eclipse中,并在Android下的项目属性中将项目指向这些库即可。

You are good to go! 你已准备好出发!

Great article on GIT(jump to the submodules section if you are familiar with git) http://www.vogella.com/tutorials/Git/article.html 关于GIT的精彩文章(如果您熟悉git, 跳到子模块部分) http://www.vogella.com/tutorials/Git/article.html

Tips: 1)Add the git module with the -b option so that you can track changes from the master repo of the submodule(refer above tutorial) 2)While importing the libraries, import them as a general project(vs android proj)...for some reason eclipse was not letting me import the projects via the android project wizard. 提示:1)使用-b选项添加git模块,以便您可以跟踪子模块的主存储库中的更改(请参阅上面的教程)2)导入库时,将它们作为常规项目导入(与android proj相对)。 ..由于某种原因,eclipse不允许我通过android项目向导导入项目。 3)Understand the nuances of how Submodules work. 3)了解子模块如何工作的细微差别。

I`ll have to probably move to a sophisticated build management system sooner or later where this is handled in a different way but this works for now. 我可能迟早必须迁移到复杂的构建管理系统,在该系统中以不同的方式处理该问题,但目前仍然有效。 I tried to reference the libraries via Gradles dependency management process but getting the whole thing to work just takes soo much time for a noob. 我试图通过Gradles依赖性管理过程来引用这些库,但是对于菜鸟来说,使整个过程正常工作只会花费太多时间。 Feel free to post questions if something was not clear. 如果有不清楚的地方,请随时发表问题。 Hope this saves people time. 希望这可以节省人们的时间。

you may need Android Studio ,based on a new building system gradle. 您可能需要基于新构建系统gradle的Android Studio

when you need import a library,you just need to put a single line in build.gradle if this library is in Maven Central Repository.Android Studio will automatically download library, then you can use it in you code.You don't have to care too much about managing multiple libraries 当您需要导入库时,如果该库位于Maven Central Repository中,则只需在build.gradle中放一行即可.Android Studio会自动下载库,然后您就可以在代码中使用它了。太在乎管理多个库

if you're developing individually,switching to Android Studio is a better choice. 如果您是单独开发,则切换到Android Studio是一个更好的选择。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM