java 将 org.apache.commons 导入 android 应用程序
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/2146870/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Importing org.apache.commons into android applications
提问by dotty
Hay, how do i import org.apache.commons packages into android so i can use them in my applications?
嘿,我如何将 org.apache.commons 包导入到 android 中,以便我可以在我的应用程序中使用它们?
Thanks
谢谢
采纳答案by Nikola Smiljani?
If you're using eclipse:
如果您使用的是日食:
- Download jar packages for libraries you are interested in
- Go to project properties in eclipse -> Java Build Path -> Libraries. Add External JARs here.
- 下载您感兴趣的库的 jar 包
- 转到 eclipse 中的项目属性 -> Java Build Path -> Libraries。在此处添加外部 JAR。
回答by MattK
Just for completeness' sake - if you aren't using eclipse to develop and you are building with ant - just put the jar in your libs folder of your project.
Done!
只是为了完整起见 - 如果您不使用 eclipse 进行开发并且您正在使用 ant 进行构建 - 只需将 jar 放在您项目的 libs 文件夹中。
完毕!
回答by Zds
Also, be warned that not all of them can be automatically converted to Dalvik. For example commons-httpclient does not convert cleanly from the release binaries, you need to go through source to make it work.
另外,请注意并非所有这些都可以自动转换为 Dalvik。例如,commons-httpclient 不会从发布二进制文件中完全转换,您需要通过源代码才能使其工作。
回答by lucidbrot
If you are using android Stuido - that doesn't yet supports adding libraries - you need to edit the src/build.gradle
如果您使用的是 android Stuido - 尚不支持添加库 - 您需要编辑 src/build.gradle
I wanted to add org.apache.commons.net and My file called 'org.apache.commons.net.jar' was placed in the libs folder, so my build.gradles dependencies look now like this:
我想添加 org.apache.commons.net 并将名为“org.apache.commons.net.jar”的文件放在 libs 文件夹中,因此我的 build.gradles 依赖项现在如下所示:
dependencies {
compile files('libs/android-support-v4.jar')
compile files('libs/org.apache.commons.net.jar')
}

