Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to resolve the java.lang.UnsatisfiedLinkError in NDK in Android?

Tags:

android-ndk

I am new in ndk development in android.I have gone through the file system of ndk android. Here, explaining what i have done. 1) i have created a folder named "jni" then create 2 file named Android.mk and ndkfoo.c.

In Android.mk

LOCAL_PATH := $(call my-dir)

include $(CLEAR_VARS)

# Here we give our module name and source file(s)
LOCAL_MODULE    := ndkfoo
LOCAL_SRC_FILES := ndkfoo.c

include $(BUILD_SHARED_LIBRARY)

and in ndkfoo.c

#include <string.h>
#include <jni.h>

jstring Java_com_mindtherobot_samples_ndkfoo_NdkFooActivity_invokeNativeFunction(JNIEnv* env, jobject javaThis) {
 return (*env)->NewStringUTF(env, "Hello from native code!");
}

then i have created NdkFooActivity class, in which i have written

// load the library - name matches jni/Android.mk
 static {
  System.loadLibrary("ndkfoo");
 }

But now when i build from cygwin in xp it creates .so file successfully then i run as android application. It gives me java.lang.UnsatisfiedLinkError in LOGCAT.

So, Please let me know where i am wrong.

Thanks in Advance,

like image 576
Indrajit Kumar Avatar asked Sep 10 '25 08:09

Indrajit Kumar


1 Answers

I think you forgot to change the package name.

Java_com_mindtherobot_samples_ndkfoo

It should be your package what you have specified creating project.

like image 52
StarDust Avatar answered Sep 13 '25 07:09

StarDust