导出签名的 apk 时出现 NoSuchMethodError
我尝试编译 reddit-is-fun,一个适用于 Android 的 reddit 阅读器。如果我从 ADT 启动应用程序(通过调试或简单运行),它将在我的手机 (HTC Desire) 上启动并正确运行。但是,如果我导出签名和压缩对齐的包并安装它,它将无法工作。 logcat 显示 Jackson 的 NoSuchMethodError 异常。它是两个 jar,存在于存储库中并添加到构建路径中。我确保这两个版本具有相同的版本,甚至用更新的版本替换了它们。
我不太熟悉使用 jar 库。它们是否“链接”到生成的 apk 中,就像编译 C++ 时静态库链接到可执行文件一样?如何确保设备上的应用程序将加载用于编译的相同版本? (这很可能是问题所在)。
I tried to compile reddit-is-fun, a reddit reader for Android. If I start the application from ADT (either by debug or simply running) it will launch and run correctly on my phone (HTC Desire). However, if I export a signed and zipaligned package and install it, it will not work. The logcat shows NoSuchMethodError exceptions for Jackson. It is two jars, present in the repository and added to the build path. I made sure that the two have the same versions and even replaced them with newer ones.
I'm not really familiar with using jar libraries. Are they "linked" into the resulting apk like a static library is linked to an executable when compiling C++? How can I make sure that the app on the device will load the same version used for compiling? (which is most likely the problem).
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
听起来 Proguard 混淆正在破坏它。尝试禁用Proguard进行确认(或者将Jackson添加到
proguard.cfg
中的白名单中)Sounds like the Proguard obfuscation is breaking it. Try disabling Proguard to confirm (or add Jackson to the whitelist in
proguard.cfg
)我认为这意味着您的 JAR 未正确从 JVM 格式转换为 Dalvik VM 格式。如您所知,Android 使用与普通桌面 JVM 不同的字节码。您应该将 JAR 从 JVM 字节码转换为 Dalvik 字节码。尝试谷歌“将 JVM 转换为 Dalvik”
I think it means that your JARs are not correctly translated from JVM format to Dalvik VM format. As you know Android uses different bytecode than ordinary desktop JVM. You should convert your JARs from JVM bytecode to Dalvik's bytecode. Try to Google "convert JVM to Dalvik"