0

I have followed all the steps mentioned in this answer(Link).

But still I am getting the same Unsatisfied Link Error as shown below.

11-11 12:38:22.304: E/AndroidRuntime(19180): FATAL EXCEPTION: main 11-11 12:38:22.304: E/AndroidRuntime(19180): java.lang.UnsatisfiedLinkError: mAdd

Here's the screen shot of our app which obtained from Native Libs Monitor

PS: We have generated the .so file using NDK build from Android instead of cygwin64.

Could you please convey me what is the real problem here ?

enter image description here

== Update ==

Please go through the following image

Inside libAddition.so file,

native method public native int mAdd(int v1,int v2); is declared in Addition.java file.

Header file is generated, for this java file using javah which contains this declaration,

JNIEXPORT jint JNICALL Java_com_example_testsampleso_Addition_mAdd
  (JNIEnv *, jobject, jint, jint);

Here, my question is

why method signature or Entry point Java_com_example_testsampleso_Addition_mAdd in generated header file and Java_com_ndkadd_Addition_Addition_mAdd in .so file is different ?

is that the reason for unsatisfied linker error ?

enter image description here

Community
  • 1
  • 1
Sankar Ganesh PMP
  • 11,927
  • 11
  • 57
  • 90
  • Do you have a native method named **mAdd()** declared in your Java class? Most likely, you can find an *exported function* named `Java_blablabla_mAdd` in **libAddition.so**. This blablabla should match the full name of your class. Note that you are not obliged to put your class in the `com.example.testadditionso` package, as generated by default by the IDE. The packages in Android are not sealed. – Alex Cohn Nov 11 '15 at 07:47

1 Answers1

0

Your Java class is com.example.testsampleso.Addition, but the library was built to be used with Java class com.ndkadd.Addition.Addition.

You can only call the mAdd native method from the Java class with correct name (and package name). This name does not fit your Android package name, but there is no problem with that.

You can add any class with any package name to your APK.

Alex Cohn
  • 56,089
  • 9
  • 113
  • 307