如何解决Android中的NDK的java.lang.UnsatisfiedLinkError中? [英] How to resolve the java.lang.UnsatisfiedLinkError in NDK in Android?
问题描述
我在android.I NDK开发新通过的Android NDK的文件系统都没有了。
在这里,解释我做了什么。
1)我创建了一个名为JNI文件夹中再创建2文件名为Android.mk和ndkfoo.c。
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.
在Android.mk
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)
和在ndkfoo.c
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!");
}
然后我创建NdkFooActivity类,其中我写
then i have created NdkFooActivity class, in which i have written
// load the library - name matches jni/Android.mk
static {
System.loadLibrary("ndkfoo");
}
但现在当我在XP cygwin的版本构建它创建的.so文件成功,然后我作为运行Android应用程序。它给我java.lang.UnsatisfiedLinkError中的logcat中。
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.
在预先感谢
推荐答案
我想你忘了更改包名。
Java_com_mindtherobot_samples_ndkfoo
Java_com_mindtherobot_samples_ndkfoo
这应该是你的包已指定创建什么项目。
It should be your package what you have specified creating project.
这篇关于如何解决Android中的NDK的java.lang.UnsatisfiedLinkError中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!