Having the above error in your Android JNI app? Read on...
Up front, I\'ll say that I\'ve already solved this, in my own way, but I feel something in the Android bu
I was having the same issue and these are some of the problems I had with my project:
System.load("hello-test");
into System.loadLibrary("hello-test");
;JNIEXPORT jstring Java_com_example_testndk_TestNDK_funcNami(JNIEnv* env, jobject thiz)
: here you use Java_<java_package_name>_<java-class-name>_<function-name>
;local.properties
, in my case ndk.dir=<my-path-to-ndk-directory>
; andbuild.gradle
to also include within defaultConfig
: ndk { moduleName "hello-test" }
.com.example.testndk
TestNDK
hello-test.c
AndroidProjects/TestNDK/app/src/main/jni
IDE: Android Studio 0.8.1.
I added
extern "C"
before functions declare
ex:
extern "C"
jstring
Java_lara_myapplication_MainActivity_stringFromJNI(
JNIEnv *env,
jobject /* this */) {
std::string hello = "Hello from C++";
return env->NewStringUTF(hello.c_str());
}
then the error was gone
I've got this issue too, but for my situation, i'm using my libs in another project. And I don't think it's a matter of eclipse or android-ndk.
you may check these tips that can lead to UnsatisfiedLinkError
and it works fine for me, good luck :)
/your project/libs/armeabi/
EDIT:
UnsatisfiedLinkError
are thrown if the library is not installed into your app.apk, so it cannot be linked sucessfully.If you have a native project with LOCAL_MODULE "libXYZ", make sure to load it as
System.loadLibrary("XYZ");