如何将第三方类包含到Android apk中?
我有几个第三方类,它们作为我可以构建应用程序的库。它们包含在添加 Java Build Path -> 的文件夹中。具有“添加类文件夹”的库(在 Eclipse 中)。到目前为止,我的应用程序编译运行良好。但生成的 .apk 仅包含我的类,因此应用程序无法运行。
我如何告诉 Eclipse 将第三方类也打包到 .apk 中?
I have a couple of third party classes which serve as a library I can build my application upon. They are contained in a folder which was added Java Build Path -> Libraries (in Eclipse) with "Add Class Folder". It works fine so far an my app compiles. But the produced .apk contains only my classes and therefore the application does not run.
How can I tell Eclipse to package the third party classes into the .apk as well?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
Eclipse 会将 Android 项目类路径中的所有 3rd 方类打包到您的 apk 中。只要您使用适用于 Eclipse 的 Android SDK 插件,它就会默认执行此操作。
这是这个问题(以及许多其他问题)的重复: 如何在 Android 项目中使用外部 JAR?
Eclipse will package all 3rd party classes in your apk that are in your Android project's classpath. It does this by default, as long as you are using the Android SDK plugin for Eclipse.
This is a duplicate of this question (and many others): How can I use external JARs in an Android project?
不需要向构建路径添加任何内容。只需在项目中创建一个名为“libs”的子文件夹即可。将所有 jar 文件放入 libs 中。
Don't need to add anything to Build Path. Just create a sub-folder called "libs" in the project. Put all jar files in libs.