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 added
before functions declare
ex:
then the error was gone
First, check you have the jni files inside you libs folder in eclipse or jniLibs folder in android studio. When you checkin in any svn, cross check to check in the .so files too.
My Scenario was when Building with Android studio.
When you are building in android studio, your library .so files or (jni) files should be inside the \src\main\jniLibs\armeabi***.so folder.
where as these files will be inside the \libs\armeabi***.so in eclipse.
When building using both eclipse and android studio, you have to modify your build.gradle file as
Here I am building the project using both the android studio and the eclipse.
Had identical problem. Just cleaned project and it worked. Mystery..
In my case, while making a System Application the issue was related to permissions. After putting the ".so" files into
/system/lib/
or/system/vendor/lib/
directory, I modified the default allocated permissions 600 to 755. It worked well.