简体   繁体   English

如何将库添加到Android项目?

[英]How to add libraries to an Android project?

I would like to use Apache Commons Lang in my Android project, but I don't know how to do it. 我想在我的Android项目中使用Apache Commons Lang ,但是我不知道该怎么做。 Should I use the source or the binary? 我应该使用源代码还是二进制文件? How to proceed then in Eclipse? 然后如何在Eclipse中进行?

Should I use the source or the binary? 我应该使用源代码还是二进制文件?

Yes. 是。 :-) :-)

In other words, either should be fine. 换句话说,两者都应该很好。 Source has the advantage of allowing you to trim out stuff you don't want and fix any compatibility issues you encounter with Android. Source的优势是允许您修剪掉不需要的内容并修复Android遇到的任何兼容性问题。 OTOH, the JAR is more convenient. OTOH,JAR更加方便。

How to proceed then in Eclipse? 然后如何在Eclipse中进行?

If you are using source, just add it to your project. 如果您使用的是源代码,只需将其添加到您的项目中即可。

If you are using the JAR, add it to the libs/ directory of your project, then add it to your build path. 如果使用的是JAR,请将其添加到项目的libs/目录中,然后将其添加到构建路径中。 Be sure to use the Add JARs button in the Build Path dialog in Eclipse to refer to the JAR that is already in your libs/ directory. 确保使用Eclipse中“构建路径”对话框中的“添加JAR”按钮来引用libs/目录中已经存在的JAR。 Everything else will be taken care of for you. 其他一切都将为您照顾。

Personally, I'd go with the binary. 就个人而言,我会选择二进制文件。

Download the binary (commons-lang3-3.0-beta-bin.zip) 下载二进制文件(commons-lang3-3.0-beta-bin.zip)

Extract the jar file to somewhere you are familiar with. 将jar文件提取到您熟悉的地方。 Usually i'd have all ma java libraries in one folder (commons-lang3-3.0-beta.jar) 通常我会将所有ma java库放在一个文件夹中(commons-lang3-3.0-beta.jar)

Right click on your project in Eclipse -> build path -> add external archives 在Eclipse中右键单击您的项目->构建路径->添加外部档案

navigate to the location you saved the extracted the jar and select it.. 导航到保存提取的jar的位置并选择它。

Viola.. Thats it.. I hope it helps. 中提琴..就这样..我希望能有所帮助。

Happy Coding..!! 快乐编码..!

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

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