本文介绍了Android NDK UnsatisfiedLinkError - 一个令人惊讶的原因的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

2013 年 8 月 7 日更新:现在问题已经解决了,但是错误的原因出乎意料,所有通常的此类错误嫌疑人在开始时都被消除了,我学到了一些新东西.请参阅下面的答案.

Update 8/7/2013:The problem is solved now, but the reason for the error was quite unexpected, all the usual suspects for such errors were eliminated on start, and I have learned something new. See my answer below.

我在这里很绝望.有一个带有本机库的 Android 应用程序,我从中调用一个方法.在我测试的所有系统上都没有问题,并且该程序已在 Google Play 中发布,没有任何故障报告,被成千上万的用户使用.现在,HTC One 手机的新 ROM(Android 版本 4.2.2)显然已经出局.用户声称它是官方版本,从官方渠道升级.当他们尝试启动我的应用程序时,它崩溃了,并且堆栈跟踪显示:

I'm pretty desperate here. Have an Android app with a native library, from where I call a method. No problem on all the systems I tested, and the program was out in Google Play without any trouble reports, used by thousands of users. Now, apparently a new ROM - Android version 4.2.2 - for HTC One phone is out. Users claim that it's the official build, upgraded form the official channel. When they try to start my app, it crashes, and the stack trace says:

java.lang.UnsatisfiedLinkError: 未找到本机方法...

java.lang.UnsatisfiedLinkError: Native method not found...

我知道的方法名称就在那里,并且刚才在同一台设备上安装了 Android 4.1 时运行良好.我在模拟器中的Android 4.2.2下测试(没有这个特定的设备),没有问题.此外,用户尝试卸载并重新安装应用程序,结果相同.即使向他们发送私人构建,没有任何 ProGuard/Dexguard 保护也无济于事.

and the method name of which I know is there and worked fine a moment ago on the same device when they had Android 4.1 installed. I test it under Android 4.2.2 in emulators (don't have this particular device) and there is no problem. Also, the users tried uninstalling and reinstalling the app with the same result. Even sending them a private build, without any ProGuard/Dexguard protections does not help.

还有什么会导致 Android 上的 java.lang.UnsatisfiedLinkError?或者我应该假设这个 HTC ROM 只是有问题???有没有其他人在使用 Android 4.2.2 的 HTC One 上遇到过类似的问题?

What else can cause java.lang.UnsatisfiedLinkError on Android? Or should I assume that this HTC ROM is simply buggy??? Did anyone else have similar problems on HTC One with Android 4.2.2?

在下面的评论中,另一位开发人员建议系统可能无法找到我的本机库.我通过从设置中完全删除本机库文件在 Genymotion 4.2.2 模拟器上进行了试验.这种情况下报错信息不同,得到:

In the comments below another developer suggests that the system could have troubles finding my native library. I experimented on Genymotion 4.2.2 emulator by removing the native library file from the setup completely. The error message is different in this situation, got:

W/System.err: 由: java.lang.UnsatisfiedLinkError: 无法从加载器 dalvik.system.PathClassLoader[dexPath=/data/app/com.hyperionics.avar-2.apk,libra 加载 cldryPath=/data/app-lib/com.hyperionics.avar-2]:findLibrary 返回 null

在我从使用 Android 4.2.2 的 HTC One 用户那里收到的堆栈跟踪消息中,我看到了以下错误消息:

While in the stack trace messages I got from HTC One users with Android 4.2.2 I see this error message:

原因:java.lang.UnsatisfiedLinkError:未找到本机方法:com.hyperionics.avar.CldWrapper.detectLangNative:(Ljava/lang/String;)[Ljava/lang‌/String;

对我来说,系统似乎根据需要找到了 libcld.so 文件,但没有找到它需要的方法.为什么???我知道该方法在那里,根据需要导出,并且所有其他设备和系统,也包括这些运行 Android 4.2.2 的设备和系统,都可以找到它.只有带有 4.2.2 的 HTC One 出现故障...

To me it appears that the system finds the libcld.so file as needed, but does not find the method it needs there. Why??? I know the method is there, exported as needed, and every other device and system, also these running Android 4.2.2, finds it. Only HTC One with 4.2.2 fails there...

开始赏金 50 代表.点,因为我没有 HTC One 并且卡住了.将接受指出解决问题的方法的答案 - 回答者将测试我的代码模块.证明它有效 - 或证明这确实是最近用于 HTC One 的 Android 4.2.2 ROM 中的一个错误.有问题的应用是 https://play.google.com/store/apps/details?id=com.hyperionics.avar

Started a bounty for 50 rep. points, as I don't have HTC One and am stuck. Will accept an answer that either points a way to solving the problem - and the answering person will test my code mod. to show it works - or proves that this is really a bug in the recent Android 4.2.2 ROM for HTC One. The app in question is https://play.google.com/store/apps/details?id=com.hyperionics.avar

赏金的最后一天,仍然没有答案,没有建议......到目前为止,我收到的所有此类错误报告都来自欧洲,报告的品牌是htc_europe"或vodafone_fr".也许错误仅限于欧洲(法国+德国)...如果有人将 HTC One 和 Android 更新到 4.2.2,如果错误发生在其他国家或其他提供商,我会很感兴趣.

The last day of the bounty and still no answers, no suggestions... So far, all such error reports I get come from Europe, reported brand is "htc_europe" or "vodafone_fr". Maybe the error is localized to Europe (France + Germany) only... If there is anyone out there with HTC One and Android updated to 4.2.2, I would be interested if the error happens in other countries or with other providers.

格雷格

推荐答案

赏金期间没有满意的答案.我订购了该设备,并且必须调试设备 ROM 中最有可能是系统错误以进行 Android 4.2.2 更新...

There was no satisfactory answer during the bounty period. I ordered the device and will have to debug what most likely is a system bug in the device ROM for Android 4.2.2 update...

事实证明,有时在从 Google Play 更新应用时,未正确安装原生库.可能安装程序空间不足,或者出现其他一些奇怪的系统错误.另请参阅 这个问题和答案.

It turns out that sometimes, when updating an app from Google Play, native libraries are not installed correctly. Maybe the installer runs out of space, or some other strange system bug kicks in. Please see also this SO question and answers.

我从 Google Play 订购的 HTC One 到货了,而且……谜团解开了!同样的崩溃也发生在 Google Play 的原始 Android 4.2.2 上.问题是我的库名称:cld,它生成了一个名为 libcld.so 的共享库.显然系统有另一个同名的共享库,当然我期望的方法不存在......可能是一些插件"将另一个 libcld.so 加载到进程内存中,而我自己的库被跳过了.我重命名了原生库,程序立即开始运行.

My HTC One ordered from Google Play arrived, and... mystery solved! The same crash happened also on the original Android 4.2.2 from Google Play. The problem was my library name: cld, which produces a shared library named libcld.so. Apparently the system has another shared library with the same name, where the methods I expect are not present, of course... Probably some "plugin" loaded this other libcld.so into the process memory, and my own library was skipped. I renamed the native library and the program started working at once.

我不知道在不同版本的 Android 上可能会出现这种名称冲突...阅读此文的人是否在 NDK 文档中的某处看到了关于它的警告?我想从现在开始,我会在我创建的所有本地库上加上我的公司名称或其他名称.

I was not aware of the possibility of such name clashes on different builds of Android... Did anyone reading this see a warning somewhere in NDK docs about it? I guess I'll prefix from now on all native libraries I create with my company name or something.

这篇关于Android NDK UnsatisfiedLinkError - 一个令人惊讶的原因的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

05-18 13:13