chAmi
chAmi

Reputation: 1813

Android JNI basic application gives Exceptions while running- java.lang.ExceptionInInitializerError, java.lang.UnsatisfiedLinkError

I'm following a basic tutorial for the android jni development at http://permadi.com/blog/2011/12/running-android-ndk-examples-using-eclipse-and-sequoyah/. Before moving to problem I solved building error by setting "cmd F:\Android\android-ndk-r8\ndk-build" to build command.

Changed build command Changed build command

Hope it's not wrong. But now it gives following error. Iv'e added logcat here. Logcat

I can see two exceptions are shown here as java.lang.UnsatisfiedLinkError and java.lang.ExceptionInInitializerError. I can't figure out what is really caused. It is said that you can fix UnsatisfiedLinkError by adding libJniTest.so to correct path. But i can't find it. I've run a search on my windows machine to find libjnitest.so but it is nowhere. Is it the problem and if it is someone can say where it should be. There are more than thousand questions as same as this but i'm no where to figure it out solution after spending several hours.

Here is my code. Java code Java code Please note that iv'e commented native function call but i can see problem is with the loading library. Native code Native code

Here i add the folder structure.

enter image description here

Upvotes: 0

Views: 1841

Answers (2)

Abhishek Akhani
Abhishek Akhani

Reputation: 209

Clean and build the project again. It will be resolved. I solved it by just that.

Upvotes: 0

Chris Stratton
Chris Stratton

Reputation: 40397

You need to run $(NDK)/ndk-build from the project's main directory in order to create the .so libraries, which should be automatically copied into the libs/ folder.

This assumes that you have a proper jni/ folder with an Android.mk in it alongside your source code.

You may want to see the hello-jni example from the ndk samples directory for an official example with all the requried pieces.

Upvotes: 1

Related Questions