I successfully cross-compiled a c++ library with the android ndk-Standalone toolchain then, i created a new android application project into Eclipse and when i put mylib.so
try {
System.load("/data/data/<package name>/lib/libsample-jni.so");
} catch (UnsatisfiedLinkError e) {
System.loadLibrary("<sample-jni>"); //remove lib and .so from name
}
this will help you, Pls. check.
I recently encountered the same error. After trying out dozens of suggestions from SO, I finally figured out that the error was in my native code. even though android ndk had compiled it without any issues / warnings.
Try writing a simple main function to test your native code and compile with g++/gcc (or something similar) to check for errors.
I know its too late for the asker, but hope someone else finds this useful.
Please specify your .so file like as follow.
static {
System.loadLibrary("mylib");
}
Hope this will help you.
If you have your compiled native library (the .so
-file) in your lib/
-directory, you can refer to it without using the full path:
static{
System.load("mylib");
}
As shown in the tutorial.
Check to see if you set the right package in your Header-file: How to resolve the java.lang.UnsatisfiedLinkError in NDK in Android?
People mostly forgot cut "lib" prefix form library name. So if you have "libusb.so" your code must be System.loadLibrary("usb")...