Java.lang.UnsatisfiedLinkError

java.lang.UnsatisfiedLinkError

I use the hello-jni example, and for some reason I get java.lang.UnsatisfiedLinkError when I try to call the hello-jni library. Any ideas why? Should I ever set my path?

in HelloJni.java:

public native String stringFromJNI(); 

and

 static { System.loadLibrary("hello-jni"); } 

in hello-jni.c:

 jstring Java_com_bdunlay_hellojni_HelloJni_stringFromJNI( JNIEnv* env, jobject thiz ) { return (*env)->NewStringUTF(env, "Hello from JNI !"); } 

exception trace

.so file ... project_root / libs / armeabi / libhello-jni.so

+4
source share
4 answers

your family does not have JNIEXPORT. Usually it declares a function declaration file in the header.

We will use javah -jni to create the header.

+5
source

See android-ndk-r8b / documentation.html for more details.

By default, the sample does not contain the Application.mk file (in the / jni / folder). I fixed the problem by adding this file to my project and adding the following single entry, which allows the built-in files to create several types of processors (in particular, for x86 in my case):

 APP_ABI := armeabi armeabi-v7a x86 

After adding this file, you can run ndk-build again to create the necessary files, and then create the APK as usual.

+4
source

java.lang.UnsatisfiedLinkError: The original method did not find an exception for methods from OpenCV which means that you are trying to use OpenCV before initializing it. You can use OpenCV objects and calling methods from the library only after onManagerConnected with the status LoaderCallbackInterface.SUCCESS.

0
source

In my case, the cause of the error was: If you have several libraries loaded as

 System.loadLibrary("lib1"); System.loadLibrary("lib2"); 

and lib1 depends on lib2, you need to download lib2 first.

0
source

Source: https://habr.com/ru/post/1337263/


All Articles