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.
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: Native method not found...
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.
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?
Edit 7/24/2013
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: Caused by: java.lang.UnsatisfiedLinkError: Couldn't load cld from loader dalvik.system.PathClassLoader[dexPath=/data/app/com.hyperionics.avar-2.apk,libraryPath=/data/app-lib/com.hyperionics.avar-2]: findLibrary returned null
While in the stack trace messages I got from HTC One users with Android 4.2.2 I see this error message:
Caused by: java.lang.UnsatisfiedLinkError: Native method not found: com.hyperionics.avar.CldWrapper.detectLangNative:(Ljava/lang/String;)[Ljava/lang/String;
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...
Update 7/25/2013
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
Update 7/31/2013
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.
Greg
System.load("path to lib")
insteadSystem.loadLibrary("libName")
) usingBuild.class
from the SDK orSystem.getProperty("os.arch");
to get the CPU architecture. For your question I looked at the source code of Build.class and java.lan.Runtime. Here: grepcode.com/file/repository.grepcode.com/java/root/jdk/openjdk/… Basically, see how System.loadLibrary() works to find shared native libs. :) – DhotiSystem.load("/system/lib/"+cpuArchitectureString+"/libName");
right after you get the cpu architecture and load proper library and spare the system deciding and getting confused which lib to load. I had similar problem, I moved armeabi lib to armeabi-v7a since armeabi is supported in v7 and the exception was gone (device: HTC One X) – Dhoti