3

I have a project that I would like to add external libraries to (and have them packaged with the application) but I am not sure it is happening. I read on this link:

https://developer.android.com/guide/appendix/faq/commontasks.html

how to, but they do not show up in any of the /data/data/project directories. Does anyone know how I can confirm that the libraries were in fact added to the project for use at runtime? Thanks.

4

3 回答 3

3

如果您在项目的 Java 构建路径下将 jars 包含为 External Jars,那么这些类将被转换为 Dalvik 格式并在项目的 classes.dex 文件中可用,并打包到 .apk 中。

要确认它们可用,请尝试使用 jar 中的某些内容(Eclipse 应该在您首次提供类名时建议相关导入)构建并运行应用程序并查看它是否有效?如果它在开发中工作(例如,从 Eclipse 中的“运行”),那么当应用程序内置发布并作为 APK 分发时它也可以工作。

于 2010-04-03T23:00:36.440 回答
0

You can also place jar under one of your source folders (perhaps creating special "libs" one) and adding it to build path.

于 2010-11-29T08:26:33.197 回答
0

请注意 - 外部库(针对 Java JDK 中的某个版本或其他库编译)在 android 下运行时有时可能会出现问题。这是因为 Dalvik 运行时有自己的 Java 框架库,它提供了标准 JDK Java 框架库中的大部分(但不是全部)Java API。

您确实应该针对 android 库重新编译任何外部库,以便您可以在编译时看到任何缺少的 API - 并在那里修复问题。否则,当您从 Android 应用程序调用外部库时,您将面临在 Dalvik 下运行时错误的风险。 有关详细信息,请参阅http://geekswithblogs.net/cyberycon/archive/2011/05/17/using-external-libraries-with-android.aspx 。

于 2011-06-10T15:54:50.077 回答