android jni开发中常见的错误

1.android.mk文件不存在

Android NDK: Your APP_BUILD_SCRIPT points to an unknown file: /cygdrive/d/jniCode/HelloJni/jni/Android.mk
/cygdrive/d/android-ndk-r9b/build/core/add-application.mk:171: *** Android NDK: Aborting...    。 停止。
2.android.mk文件的配置信息有错误

/cygdrive/d/android-ndk-r9b/build/core/build-shared-library.mk:23: *** Android NDK: Missing LOCAL_MODULE before including BUILD_SHARED_LIBRARY in /cygdrive/d/jniCode/HelloJni/jni/Android.mk    。 停止。

3.c代码语法错误,编译不通过

[armeabi] Gdbserver      : [arm-linux-androideabi-4.6] libs/armeabi/gdbserver
[armeabi] Gdbsetup       : libs/armeabi/gdb.setup
[armeabi] Compile thumb  : hello-jni <= hello-jni.c
D:/jniCode/HelloJni/jni/hello-jni.c: In function 'Java_com_example_hellojni_HelloJni_stringFromJNI':
D:/jniCode/HelloJni/jni/hello-jni.c:37:14: error: invalid type argument of '->' (have 'int')
/cygdrive/d/android-ndk-r9b/build/core/build-binary.mk:384: recipe for target '/cygdrive/d/jniCode/HelloJni/obj/local/armeabi/objs-debug/hello-jni/hello-jni.o' failed
make: *** [/cygdrive/d/jniCode/HelloJni/obj/local/armeabi/objs-debug/hello-jni/hello-jni.o] Error 1

4. java存C代码库没有找到
: java.lang.ExceptionInInitializerError
:     at java.lang.Class.newInstanceImpl(Native Method)
:     at java.lang.Class.newInstance(Class.java:1409)
:     at android.app.Instrumentation.newActivity(Instrumentation.java:1040)
:     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1777)
:     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1893)
:     at android.app.ActivityThread.access$1500(ActivityThread.java:135)
:     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1054)
:     at android.os.Handler.dispatchMessage(Handler.java:99)
:     at android.os.Looper.loop(Looper.java:150)
:     at android.app.ActivityThread.main(ActivityThread.java:4385)
:     at java.lang.reflect.Method.invokeNative(Native Method)
:     at java.lang.reflect.Method.invoke(Method.java:507)
:     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:849)
:     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:607)
:     at dalvik.system.NativeStart.main(Native Method)
: Caused by: java.lang.UnsatisfiedLinkError: Couldn't load hello-: findLibrary returned null
:     at java.lang.Runtime.loadLibrary(Runtime.java:429)
:     at java.lang.System.loadLibrary(System.java:554)
:     at com.example.hellojni.HelloJni.<clinit>(HelloJni.java:66)
:     ... 15 more


5.c代码函数签名出现错误
12-23 22:00:52.096: ERROR/AndroidRuntime(12694): FATAL EXCEPTION: main
12-23 22:00:52.096: ERROR/AndroidRuntime(12694): java.lang.UnsatisfiedLinkError: hello_from_c
12-23 22:00:52.096: ERROR/AndroidRuntime(12694):     at com.example.hellojni.HelloJni.hello_from_c(Native Method)
12-23 22:00:52.096: ERROR/AndroidRuntime(12694):     at com.example.hellojni.HelloJni.onCreate(HelloJni.java:36)
12-23 22:00:52.096: ERROR/AndroidRuntime(12694):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1072)
12-23 22:00:52.096: ERROR/AndroidRuntime(12694):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1836)
12-23 22:00:52.096: ERROR/AndroidRuntime(12694):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1893)
12-23 22:00:52.096: ERROR/AndroidRuntime(12694):     at android.app.ActivityThread.access$1500(ActivityThread.java:135)
12-23 22:00:52.096: ERROR/AndroidRuntime(12694):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1054)
12-23 22:00:52.096: ERROR/AndroidRuntime(12694):     at android.os.Handler.dispatchMessage(Handler.java:99)
12-23 22:00:52.096: ERROR/AndroidRuntime(12694):     at android.os.Looper.loop(Looper.java:150)
12-23 22:00:52.096: ERROR/AndroidRuntime(12694):     at android.app.ActivityThread.main(ActivityThread.java:4385)
12-23 22:00:52.096: ERROR/AndroidRuntime(12694):     at java.lang.reflect.Method.invokeNative(Native Method)
12-23 22:00:52.096: ERROR/AndroidRuntime(12694):     at java.lang.reflect.Method.invoke(Method.java:507)
12-23 22:00:52.096: ERROR/AndroidRuntime(12694):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:849)
12-23 22:00:52.096: ERROR/AndroidRuntime(12694):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:607)
12-23 22:00:52.096: ERROR/AndroidRuntime(12694):     at dalvik.system.NativeStart.main(Native Method)
12-23 22:00:53.007: ERROR/HtcHardwareService(1449): Headset type is not existed
12-23 22:00:53.528: ERROR/MSF.S.AppProcessManager(7521): [E]can not find com.tencent.mobileqq to receive msg to:ToServiceMsg msName:_msf_UnRegPush ssoSeq:2182 appId:537036477 appSeq:41 sName: uin:245972074 sCmd:push.unRegister t:30000 needResp:true from:FromServiceMsg msName:unRegisterPush ssoSeq:2182 failCode:1000 errorMsg: uin:245972074 serviceCmd:push.unRegister appId:537036477 appSeq:41

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




你可能感兴趣的:(android jni开发中常见的错误)