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?
I've got this issue too, but for my situation, i'm using my libs in another project. And I don't think it's a matter of eclipse or android-ndk.
you may check these tips that can lead to
UnsatisfiedLinkError
and it works fine for me, good luck :)/your project/libs/armeabi/
EDIT:
UnsatisfiedLinkError
are thrown if the library is not installed into your app.apk, so it cannot be linked sucessfully.If you have a native project with "libXYZ.so", make sure that /system/lib/libXYZ.so does not exist on your device. There is a painful workaround: use
instead of System.loadLibrary().
I just had this happen and the problem was that the device simply did not have enough space to install the library. I uninstalled some other apps and then it worked.
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.
Add this following code inside your gradle file
So, Android Studio keep on looking native libs inside jniLibs folder. this code will change the path of android studio to look libs in libs folder
No need to root the device..deploy app on emulator and browse the folder