Reputation: 3182
IDE: Android Studio
I have the static library located under the "jniLibs" folder.
I also loaded that library. Here is the code I used:
static
{
System.loadLibrary("elianjni");
}
The native methods were declared on a separate class(ElianNative) as:
public native int InitSmartConnection(String paramString, int paramInt1, int paramInt2);
public native int StartSmartConnection(String paramString1, String paramString2, String paramString3, byte paramByte);
However when I called the method InitSmartConnection
the app crashed and the error was:
java.lang.UnsatisfiedLinkError: Native method not found: com.monitor.camera.connect.ElianNative.InitSmartConnection:(Ljava/lang/String;II)I
at com.monitor.camera.connect.ElianNative.InitSmartConnection(Native Method)
I don't know the possible cause of this because I just copied this library from another WORKING project and then did the same thing on declaring the methods and importing the necessary headers.
What can be the possible cause of such problem? I searched on stack, some say that it's the absence of Java keyword before the method in the .c file. However I don't think that this can be the problem because like what I said, this is used in another project which is working fine.
Upvotes: 1
Views: 3011
Reputation: 8209
If you have copied native library binary files (.so
) from other project you must ensure that:
Also check that System.loadLibrary()
ends successfully, without error logs in logcat.
Upvotes: 5