JNI常见错误整理

ndk开发常见错误
1. android.mk文件不存在

$ ndk-build
Android NDK: Your APP_BUILD_SCRIPT points to an unknown file: ./jni/Android.mk
/cygdrive/h/heima6/jni2/ziliao/android-ndk-r7b/build/core/add-application.mk:133: *** Android NDK: Aborting... 。 停止。

2.android.mk文件 的配置信息有错误
$ ndk-build
/cygdrive/h/heima6/jni2/ziliao/android-ndk-r7b/build/core/build-shared-library.mk:23:
*** Android NDK: Missing LOCAL_MODULE before including BUILD_SHARED_LIBRARY in jni/Android.mk 。 停止。

 

3.c代码 语法出现错误,编译不通过 Error 1.
Compile thumb : Hello <= Hello.c
jni/Hello.c: In function 'Java_cn_itcast_ndk_DemoActivity_helloFromC':
jni/Hello.c:21: error: 'ctr' undeclared (first use in this function)
jni/Hello.c:21: error: (Each undeclared identifier is reported only once
jni/Hello.c:21: error: for each function it appears in.)
jni/Hello.c:21: error: expected ';' before 'c'
/cygdrive/h/heima6/jni2/ziliao/android-ndk-r7b/build/core/build-binary.mk:240: recipe for target `obj/local/armeabi/objs/Hello/Hello.o' failed
make: *** [obj/local/armeabi/objs/Hello/Hello.o] Error 1

4.java层c代码库没有找到
Caused by: java.lang.UnsatisfiedLinkError: Library Hell0 not found

静态加载代码库的时候 代码库没有找到.

5.c代码函数签名出现错误
Caused by: java.lang.UnsatisfiedLinkError: hello_from_c


6.逻辑性的错误, 使用了已经回收的内存空间, 访问了不可以被访问的内存空间,
修改了不能被修改的内存空间

 

你可能感兴趣的:(jni)