android – JNI在应用程序中检测到错误

前端之家收集整理的这篇文章主要介绍了android – JNI在应用程序中检测到错误前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我在wordpress中使用API​​来获取我拥有的标题数量.我的代码适用于除5.x之外的所有 Android版本.当我在我的应用程序中推送一个帖子时,很遗憾地关闭了.我不知道Android 5版本有什么问题.有谁知道解决方案是什么?

这是我的logcat:

04-16 19:06:54.709  18828-18828/com.example.dmb.materialnews A/art﹕ art/runtime/check_jni.cc:65] JNI DETECTED ERROR IN APPLICATION: JNI CallVoidMethodV called with pending exception 'java.lang.IllegalStateException' thrown in void android.os.MessageQueue.nativePollOnce(long,int):-2
04-16 19:06:54.709  18828-18828/com.example.dmb.materialnews A/art﹕ art/runtime/check_jni.cc:65]     in call to CallVoidMethodV
04-16 19:06:54.709  18828-18828/com.example.dmb.materialnews A/art﹕ art/runtime/check_jni.cc:65]     from void android.os.MessageQueue.nativePollOnce(long,int)
04-16 19:06:54.709  18828-18828/com.example.dmb.materialnews A/art﹕ art/runtime/check_jni.cc:65] "main" prio=5 tid=1 Runnable
04-16 19:06:54.709  18828-18828/com.example.dmb.materialnews A/art﹕ art/runtime/check_jni.cc:65]   | group="main" sCount=0 dsCount=0 obj=0x87d30ef0 self=0xb4f07800
04-16 19:06:54.709  18828-18828/com.example.dmb.materialnews A/art﹕ art/runtime/check_jni.cc:65]   | sysTid=18828 nice=-11 cgrp=apps sched=0/0 handle=0xb6fdeec8
04-16 19:06:54.709  18828-18828/com.example.dmb.materialnews A/art﹕ art/runtime/check_jni.cc:65]   | state=R schedstat=( 2249126546 506089308 3210 ) utm=183 stm=41 core=3 HZ=100
04-16 19:06:54.709  18828-18828/com.example.dmb.materialnews A/art﹕ art/runtime/check_jni.cc:65]   | stack=0xbe0c8000-0xbe0ca000 stackSize=8MB
04-16 19:06:54.709  18828-18828/com.example.dmb.materialnews A/art﹕ art/runtime/check_jni.cc:65]   | held mutexes= "mutator lock"(shared held)
04-16 19:06:54.709  18828-18828/com.example.dmb.materialnews A/art﹕ art/runtime/check_jni.cc:65]   native: #00 pc 00004640  /system/lib/libbacktrace_libc++.so (UnwindCurrent::Unwind(unsigned int,ucontext*)+23)
04-16 19:06:54.709  18828-18828/com.example.dmb.materialnews A/art﹕ art/runtime/check_jni.cc:65]   native: #01 pc 00002e8d  /system/lib/libbacktrace_libc++.so (Backtrace::Unwind(unsigned int,ucontext*)+8)
04-16 19:06:54.709  18828-18828/com.example.dmb.materialnews A/art﹕ art/runtime/check_jni.cc:65]   native: #02 pc 00248381  /system/lib/libart.so (art::DumpNativeStack(std::__1::basic_ostream<char,std::__1::char_traits<char> >&,int,char const*,art::mirror::ArtMethod*)+68)
04-16 19:06:54.709  18828-18828/com.example.dmb.materialnews A/art﹕ art/runtime/check_jni.cc:65]   native: #03 pc 0022cd0b  /system/lib/libart.so (art::Thread::Dump(std::__1::basic_ostream<char,std::__1::char_traits<char> >&) const+146)
04-16 19:06:54.709  18828-18828/com.example.dmb.materialnews A/art﹕ art/runtime/check_jni.cc:65]   native: #04 pc 000b189b  /system/lib/libart.so (art::JniAbort(char const*,char const*)+582)
04-16 19:06:54.709  18828-18828/com.example.dmb.materialnews A/art﹕ art/runtime/check_jni.cc:65]   native: #05 pc 000b1fd5  /system/lib/libart.so (art::JniAbortF(char const*,...)+60)
04-16 19:06:54.709  18828-18828/com.example.dmb.materialnews A/art﹕ art/runtime/check_jni.cc:65]   native: #06 pc 000b50e5  /system/lib/libart.so (art::ScopedCheck::ScopedCheck(_JNIEnv*,char const*)+1284)
04-16 19:06:54.709  18828-18828/com.example.dmb.materialnews A/art﹕ art/runtime/check_jni.cc:65]   native: #07 pc 000bc59f  /system/lib/libart.so (art::CheckJNI::CallVoidMethodV(_JNIEnv*,_jobject*,_jmethodID*,std::__va_list)+30)
04-16 19:06:54.709  18828-18828/com.example.dmb.materialnews A/art﹕ art/runtime/check_jni.cc:65]   native: #08 pc 00063803  /system/lib/libandroid_runtime.so (???)
04-16 19:06:54.709  18828-18828/com.example.dmb.materialnews A/art﹕ art/runtime/check_jni.cc:65]   native: #09 pc 000776bd  /system/lib/libandroid_runtime.so (android::NativeDisplayEventReceiver::dispatchVsync(long long,unsigned int)+40)
04-16 19:06:54.709  18828-18828/com.example.dmb.materialnews A/art﹕ art/runtime/check_jni.cc:65]   native: #10 pc 00077885  /system/lib/libandroid_runtime.so (android::NativeDisplayEventReceiver::handleEvent(int,void*)+80)
04-16 19:06:54.709  18828-18828/com.example.dmb.materialnews A/art﹕ art/runtime/check_jni.cc:65]   native: #11 pc 00010f6f  /system/lib/libutils.so (android::Looper::pollInner(int)+482)
04-16 19:06:54.709  18828-18828/com.example.dmb.materialnews A/art﹕ art/runtime/check_jni.cc:65]   native: #12 pc 00011019  /system/lib/libutils.so (android::Looper::pollOnce(int,int*,void**)+92)
04-16 19:06:54.709  18828-18828/com.example.dmb.materialnews A/art﹕ art/runtime/check_jni.cc:65]   native: #13 pc 000830c1  /system/lib/libandroid_runtime.so (android::NativeMessageQueue::pollOnce(_JNIEnv*,int)+22)
04-16 19:06:54.709  18828-18828/com.example.dmb.materialnews A/art﹕ art/runtime/check_jni.cc:65]   native: #14 pc 000b22d7  /system/framework/arm/boot.oat (Java_android_os_MessageQueue_nativePollOnce__JI+102)
04-16 19:06:54.709  18828-18828/com.example.dmb.materialnews A/art﹕ art/runtime/check_jni.cc:65]   at android.os.MessageQueue.nativePollOnce(Native method)
04-16 19:06:54.709  18828-18828/com.example.dmb.materialnews A/art﹕ art/runtime/check_jni.cc:65]   at android.os.MessageQueue.next(MessageQueue.java:143)
04-16 19:06:54.709  18828-18828/com.example.dmb.materialnews A/art﹕ art/runtime/check_jni.cc:65]   at android.os.Looper.loop(Looper.java:130)
04-16 19:06:54.709  18828-18828/com.example.dmb.materialnews A/art﹕ art/runtime/check_jni.cc:65]   at android.app.ActivityThread.main(ActivityThread.java:5832)
04-16 19:06:54.709  18828-18828/com.example.dmb.materialnews A/art﹕ art/runtime/check_jni.cc:65]   at java.lang.reflect.Method.invoke!(Native method)
04-16 19:06:54.709  18828-18828/com.example.dmb.materialnews A/art﹕ art/runtime/check_jni.cc:65]   at java.lang.reflect.Method.invoke(Method.java:372)
04-16 19:06:54.709  18828-18828/com.example.dmb.materialnews A/art﹕ art/runtime/check_jni.cc:65]   at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1399)
04-16 19:06:54.709  18828-18828/com.example.dmb.materialnews A/art﹕ art/runtime/check_jni.cc:65]   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1194)
04-16 19:06:54.709  18828-18828/com.example.dmb.materialnews A/art﹕ art/runtime/check_jni.cc:65]
04-16 19:06:55.509  18828-18828/com.example.dmb.materialnews A/art﹕ art/runtime/runtime.cc:286]   native: #08 pc 000b1a79  /system/lib/libart.so (art::JniAbort(char const*,char const*)+1060)
04-16 19:06:55.509  18828-18828/com.example.dmb.materialnews A/art﹕ art/runtime/runtime.cc:286]   native: #09 pc 000b1fd5  /system/lib/libart.so (art::JniAbortF(char const*,...)+60)
04-16 19:06:55.509  18828-18828/com.example.dmb.materialnews A/art﹕ art/runtime/runtime.cc:286]   native: #10 pc 000b50e5  /system/lib/libart.so (art::ScopedCheck::ScopedCheck(_JNIEnv*,char const*)+1284)
04-16 19:06:55.509  18828-18828/com.example.dmb.materialnews A/art﹕ art/runtime/runtime.cc:286]   native: #11 pc 000bc59f  /system/lib/libart.so (art::CheckJNI::CallVoidMethodV(_JNIEnv*,std::__va_list)+30)
04-16 19:06:55.519  18828-18828/com.example.dmb.materialnews A/art﹕ art/runtime/runtime.cc:286]   native: #17 pc 000830c1  /system/lib/libandroid_runtime.so (android::NativeMessageQueue::pollOnce(_JNIEnv*,int)+22)
04-16 19:06:55.519  18828-18828/com.example.dmb.materialnews A/art﹕ art/runtime/runtime.cc:286]   native: #08 pc 000b1a79  /system/lib/libart.so (art::JniAbort(char const*,char const*)+1060)
04-16 19:06:55.519  18828-18828/com.example.dmb.materialnews A/art﹕ art/runtime/runtime.cc:286]   native: #09 pc 000b1fd5  /system/lib/libart.so (art::JniAbortF(char const*,...)+60)
04-16 19:06:55.519  18828-18828/com.example.dmb.materialnews A/art﹕ art/runtime/runtime.cc:286]   native: #10 pc 000b50e5  /system/lib/libart.so (art::ScopedCheck::ScopedCheck(_JNIEnv*,char const*)+1284)
04-16 19:06:55.519  18828-18828/com.example.dmb.materialnews A/art﹕ art/runtime/runtime.cc:286]   native: #11 pc 000bc59f  /system/lib/libart.so (art::CheckJNI::CallVoidMethodV(_JNIEnv*,int)+22)
04-16 19:06:55.529  18828-18828/com.example.dmb.materialnews A/art﹕ art/runtime/runtime.cc:286]   native: #04 pc 001fc499  /system/lib/libart.so (art::Object_wait(_JNIEnv*,_jobject*)+32)
04-16 19:06:55.529  18828-18828/com.example.dmb.materialnews A/art﹕ art/runtime/runtime.cc:286]   native: #04 pc 001fc471  /system/lib/libart.so (art::Object_waitJI(_JNIEnv*,long long,int)+36)
04-16 19:06:55.529  18828-18828/com.example.dmb.materialnews A/art﹕ art/runtime/runtime.cc:286]   native: #04 pc 001fc499  /system/lib/libart.so (art::Object_wait(_JNIEnv*,_jobject*)+32)
04-16 19:06:55.529  18828-18828/com.example.dmb.materialnews A/art﹕ art/runtime/runtime.cc:286]   native: #04 pc 001fc499  /system/lib/libart.so (art::Object_wait(_JNIEnv*,int)+36)
04-16 19:06:55.529  18828-18828/com.example.dmb.materialnews A/art﹕ art/runtime/runtime.cc:286]   native: #04 pc 001fc471  /system/lib/libart.so (art::Object_waitJI(_JNIEnv*,int)+36)
04-16 19:06:55.529  18828-18828/com.example.dmb.materialnews A/art﹕ art/runtime/runtime.cc:286]   native: #05 pc 000830c1  /system/lib/libandroid_runtime.so (android::NativeMessageQueue::pollOnce(_JNIEnv*,int)+22)
04-16 19:06:55.529  18828-18828/com.example.dmb.materialnews A/art﹕ art/runtime/runtime.cc:286]   native: #05 pc 000830c1  /system/lib/libandroid_runtime.so (android::NativeMessageQueue::pollOnce(_JNIEnv*,int)+22)
04-16 19:06:55.529  18828-18828/com.example.dmb.materialnews A/art﹕ art/runtime/runtime.cc:286]   native: #04 pc 001fc471  /system/lib/libart.so (art::Object_waitJI(_JNIEnv*,int)+36)
04-16 19:06:55.539  18828-18828/com.example.dmb.materialnews A/art﹕ art/runtime/runtime.cc:286]   native: #04 pc 001fc471  /system/lib/libart.so (art::Object_waitJI(_JNIEnv*,int)+36)

解决方法

Android 5.0使用不同的虚拟机(以前是Dalvik,现在是ART).这个新VM对JNI代码要严格得多.
现在进行的检查之一是不允许您在异常中调用本机代码.
您可以在 http://developer.android.com/training/articles/perf-jni.html#exceptions找到更多详细信息. 如果您不是本机库的作者,则作者需要更正它.同时,您可以通过避免Java的异常来避免对本机调用调用,但如果异常发生在您不拥有的库中,则可能无法实现…

猜你在找的Android相关文章