Android NDK java.lang.UnsatisfiedLinkError: findLibrary returned null

Having the above error in your Android JNI app? Read on...

Up front, I'll say that I've already solved this, in my own way, but I feel something in the Android build system (perhaps regarding Eclipse) is broke, and I hope to save someone else hours of pain. Perhaps others have come across this issue and can comment on what worked for them.

For a while, I've had an Android project with some JNI code that I developed using the NDK. Then, today, I changed something in the java code and then poof, I could no longer load my JNI library. It failed with an exception like:

E/AndroidRuntime( 999): java.lang.UnsatisfiedLinkError: Couldn't load mylibrary: findLibrary returned null

I googled and tried everything (rebuilding, close and relaunch Eclipse, etc, etc)

What finally fixed my problem? I physically uninstalled my app from the device before trying another run. That's it. After that, it worked. What worked for you?


Solution 1:

If you have a native project with LOCAL_MODULE "libXYZ", make sure to load it as

System.loadLibrary("XYZ");

Solution 2:

If you are trying to run your app in a simulator, then make sure that you have specified the correct architecture in Run -> Run Configurations -> Target (you may need to add the required simulator using Window -> Android Virtual Device Manager).

I had the same problem when trying to execute an app in an Intel simulator, while the app was using a library precompiled for the ARM.