最近使用NDK进行项目开发过程中,debug模式下logcat输出以下错误(PS:正常run没有任何错误,JNI方法执行没有问题):
05-28 13:48:10.422: W/dalvikvm(15024): JNI WARNING: input is not valid Modified UTF-8: illegal start byte 0xa5
05-28 13:48:10.422: W/dalvikvm(15024): string: ‘h??n?@?3‘
05-28 13:48:10.422: W/dalvikvm(15024): in Lcom/sina/client/base/utils/Message;.decrypt:(Ljava/lang/String;)Ljava/lang/String; (NewStringUTF)
05-28 13:48:10.422: I/dalvikvm(15024): "main" prio=5 tid=1 NATIVE
05-28 13:48:10.422: I/dalvikvm(15024): | group="main" sCount=0 dsCount=0 obj=0x415df700 self=0x400ca0b8
05-28 13:48:10.422: I/dalvikvm(15024): | sysTid=15024 nice=0 sched=0/0 cgrp=apps handle=1075232560
05-28 13:48:10.422: I/dalvikvm(15024): | schedstat=( 0 0 0 ) utm=38 stm=8 core=3
05-28 13:48:10.442: I/dalvikvm(15024): #00 pc 00001260 /system/lib/libcorkscrew.so (unwind_backtrace_thread+27)
05-28 13:48:10.442: I/dalvikvm(15024): #01 pc 0005ff8c /system/lib/libdvm.so (dvmDumpNativeStack(DebugOutputTarget const*, int)+35)
05-28 13:48:10.442: I/dalvikvm(15024): #02 pc 0005471e /system/lib/libdvm.so (dvmDumpThreadEx(DebugOutputTarget const*, Thread*, bool)+289)
05-28 13:48:10.442: I/dalvikvm(15024): #03 pc 000547ae /system/lib/libdvm.so (dvmDumpThread(Thread*, bool)+25)
05-28 13:48:10.442: I/dalvikvm(15024): #04 pc 0003aa3e /system/lib/libdvm.so
05-28 13:48:10.442: I/dalvikvm(15024): #05 pc 0003bcb8 /system/lib/libdvm.so
05-28 13:48:10.442: I/dalvikvm(15024): #06 pc 0003dfda /system/lib/libdvm.so
05-28 13:48:10.442: I/dalvikvm(15024): #07 pc 000044e8 /data/data/com.donfer/lib/libdfclient.so (Java_com_donfer_client_base_utils_DFMessageFactory_decryptMsg+67)
05-28 13:48:10.442: I/dalvikvm(15024): #08 pc 0001fb70 /system/lib/libdvm.so (dvmPlatformInvoke+112)
05-28 13:48:10.442: I/dalvikvm(15024): #09 pc 0004e8b8 /system/lib/libdvm.so (dvmCallJNIMethod(unsigned int const*, JValue*, Method const*, Thread*)+359)
05-28 13:48:10.442: I/dalvikvm(15024): #10 pc 00050600 /system/lib/libdvm.so (dvmResolveNativeMethod(unsigned int const*, JValue*, Method const*, Thread*)+171)
05-28 13:48:10.442: I/dalvikvm(15024): #11 pc 0005fd74 /system/lib/libdvm.so (dvmCallMethodA(Thread*, Method const*, Object*, bool, JValue*, jvalue const*)+247)
05-28 13:48:10.442: I/dalvikvm(15024): #12 pc 000457a6 /system/lib/libdvm.so (dvmDbgExecuteMethod(DebugInvokeReq*)+85)
05-28 13:48:10.442: I/dalvikvm(15024): #13 pc 00061b14 /system/lib/libdvm.so
05-28 13:48:10.442: I/dalvikvm(15024): #14 pc 00061d4c /system/lib/libdvm.so (dvmJdwpPostLocationEvent(JdwpState*, JdwpLocation const*, unsigned long long, int)+359)
05-28 13:48:10.452: I/dalvikvm(15024): #15 pc 000453e0 /system/lib/libdvm.so (dvmDbgPostLocationEvent(Method const*, int, Object*, int)+75)
05-28 13:48:10.452: I/dalvikvm(15024): #16 pc 0002d580 /system/lib/libdvm.so (dvmCheckBefore+504)
05-28 13:48:10.452: I/dalvikvm(15024): #17 pc 000237fc /system/lib/libdvm.so
05-28 13:48:10.452: I/dalvikvm(15024): #18 pc 0002d7e8 /system/lib/libdvm.so (dvmInterpret(Thread*, Method const*, JValue*)+180)
05-28 13:48:10.452: I/dalvikvm(15024): #19 pc 0006017e /system/lib/libdvm.so (dvmInvokeMethod(Object*, Method const*, ArrayObject*, ArrayObject*, ClassObject*, bool)+373)
05-28 13:48:10.452: I/dalvikvm(15024): #20 pc 00067124 /system/lib/libdvm.so
05-28 13:48:10.452: I/dalvikvm(15024): #21 pc 00029020 /system/lib/libdvm.so
05-28 13:48:10.452: I/dalvikvm(15024): #22 pc 0002d7e8 /system/lib/libdvm.so (dvmInterpret(Thread*, Method const*, JValue*)+180)
05-28 13:48:10.452: I/dalvikvm(15024): #23 pc 0005fed4 /system/lib/libdvm.so (dvmCallMethodV(Thread*, Method const*, Object*, bool, JValue*, std::__va_list)+271)
05-28 13:48:10.452: I/dalvikvm(15024): #24 pc 0004aee6 /system/lib/libdvm.so
05-28 13:48:10.452: I/dalvikvm(15024): #25 pc 00048c72 /system/lib/libandroid_runtime.so
05-28 13:48:10.452: I/dalvikvm(15024): #26 pc 00049690 /system/lib/libandroid_runtime.so (android::AndroidRuntime::start(char const*, char const*)+367)
05-28 13:48:10.452: I/dalvikvm(15024): #27 pc 00000dce /system/bin/app_process
05-28 13:48:10.452: I/dalvikvm(15024): #28 pc 00017190 /system/lib/libc.so (__libc_init+35)
05-28 13:48:10.452: I/dalvikvm(15024): at com.donfer.client.base.utils.DFMessageFactory.decryptMsg(Native Method)
05-28 13:48:10.452: I/dalvikvm(15024): at com.donfer.project.ActivityWelcome.onError(ActivityWelcome.java:-1)
05-28 13:48:10.452: I/dalvikvm(15024): at com.donfer.client.base.DFActivityBase.onError(DFActivityBase.java:600)
05-28 13:48:10.452: I/dalvikvm(15024): at com.donfer.client.base.DFActivityBase$3.onError(DFActivityBase.java:124)
05-28 13:48:10.452: I/dalvikvm(15024): at com.donfer.client.base.io.DFHttpTask.onError(DFHttpTask.java:100)
05-28 13:48:10.452: I/dalvikvm(15024): at com.donfer.client.base.io.DFHttpTask.onPostExecute(DFHttpTask.java:91)
05-28 13:48:10.452: I/dalvikvm(15024): at com.donfer.client.base.io.DFHttpTask.onPostExecute(DFHttpTask.java:1)
05-28 13:48:10.452: I/dalvikvm(15024): at android.os.AsyncTask.finish(AsyncTask.java:631)
05-28 13:48:10.452: I/dalvikvm(15024): at android.os.AsyncTask.access$600(AsyncTask.java:177)
05-28 13:48:10.452: I/dalvikvm(15024): at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:644)
05-28 13:48:10.452: I/dalvikvm(15024): at android.os.Handler.dispatchMessage(Handler.java:99)
05-28 13:48:10.452: I/dalvikvm(15024): at android.os.Looper.loop(Looper.java:137)
05-28 13:48:10.452: I/dalvikvm(15024): at android.app.ActivityThread.main(ActivityThread.java:4875)
05-28 13:48:10.452: I/dalvikvm(15024): at java.lang.reflect.Method.invokeNative(Native Method)
05-28 13:48:10.452: I/dalvikvm(15024): at java.lang.reflect.Method.invoke(Method.java:511)
05-28 13:48:10.452: I/dalvikvm(15024): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:804)
05-28 13:48:10.452: I/dalvikvm(15024): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:571)
05-28 13:48:10.452: I/dalvikvm(15024): at dalvik.system.NativeStart.main(Native Method)
05-28 13:48:10.452: E/dalvikvm(15024): VM aborting
05-28 13:48:10.452: A/libc(15024): Fatal signal 11 (SIGSEGV) at 0xdeadd00d (code=1), thread 15024 (com.donfer)
网上看了很多帖子都说是编码的问题,需要修改CheckJNI.c
后来开始怀疑NDK的版本问题,本人使用的NDK为:android-ndk-r9-darwin-x86_64.tar.bz2。
于是去官网看了下NDK的版本修复记录,发现正好本人的NDK版本是在bug修复前下载的,于是果断下载最新的NDK。
Google官方网站:http://developer.android.com/tools/sdk/ndk/index.html
Android NDK, Revision 9c (December 2013)
This is a bug-fix-only release.
Check_ReleaseStringUTFChars
in /system/lib/libdvm.so
that
was causing crashes on x86 devices.JNI WARNING: input is not valid Modified UTF-8,布布扣,bubuko.com
JNI WARNING: input is not valid Modified UTF-8
原文地址:http://blog.csdn.net/gufeibaixue/article/details/27331415