gpt4 book ai didi

java - Android 外部库项目上的 NoClassDefFoundError

转载 作者:IT王子 更新时间:2023-10-28 23:36:54 26 4
gpt4 key购买 nike

我使用 eclipse 进行 Google Android 开发。

我创建了一个库项目(Android 设置中的 [x] Is Library),其中包含一个外部 jar 文件(引用库)。此库项目在另一个项目(将使用库项目的实际项目)中引用。这是通过在 Android-settings 下添加项目来完成的。

源代码编译,但如果我想在设备上执行它,我会得到一个类的 NoClassDefFoundError,该类在库项目中包含的 jar 文件中

编辑: jar 文件添加到导出的条目(Order and Export-Tab 上的[x] my.jar来自图书馆项目)

有没有一种干净的方法可以让它工作?

最佳答案

官方API中有明确说明here :

A library project can include a JAR library

You can develop a library project that itself includes a JAR library, however you need to manually edit the dependent application project's build path and add a path to the JAR file

jar lib 必须手动添加到依赖应用程序项目的构建路径中,而不仅仅是库项目构建路径本身。

从 SDK r17 更新:

现在由 ADT 自动处理,查看 ADT 17.0.0 版本的新功能 here :

Added feature to automatically setup JAR dependencies. Any .jar files in the /libs folder are added to the build configuration (similar to how the Ant build system works). Also, .jar files needed by library projects are also automatically added to projects that depend on those library projects. (more info)

关于java - Android 外部库项目上的 NoClassDefFoundError,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7994715/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com