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.邏輯性的錯誤, 使用了已經回收的內存空間, 訪問了不可以被訪問的內存空間,
修改了不能被修改的內存空間