Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

开启混淆后报错“JNI DETECTED ERROR IN APPLICATION” #7

Closed
xmaihh opened this issue Dec 5, 2019 · 1 comment
Closed

开启混淆后报错“JNI DETECTED ERROR IN APPLICATION” #7

xmaihh opened this issue Dec 5, 2019 · 1 comment

Comments

@xmaihh
Copy link
Owner

xmaihh commented Dec 5, 2019

开启混淆后运行报错,得到错误信息

 A/art: art/runtime/check_jni.cc:65] JNI DETECTED ERROR IN APPLICATION: JNI GetFieldID called with pending exception 'java.lang.NoSuchFieldError' thrown in void android_serialport_api.SerialPort.close():-2
 A/art: art/runtime/check_jni.cc:65]     in call to GetFieldID
 A/art: art/runtime/check_jni.cc:65]     from void android_serialport_api.SerialPort.close()
 A/art: art/runtime/check_jni.cc:65] "IntentService[KitchenAid]" prio=5 tid=22 Runnable
 A/art: art/runtime/check_jni.cc:65]   | group="main" sCount=0 dsCount=0 obj=0x12f477b0 self=0xb4846b00
 A/art: art/runtime/check_jni.cc:65]   | sysTid=6585 nice=0 cgrp=default sched=0/0 handle=0xb4928e00
 A/art: art/runtime/check_jni.cc:65]   | state=R schedstat=( 1392412644 43181446 156 ) utm=137 stm=2 core=3 HZ=100
 A/art: art/runtime/check_jni.cc:65]   | stack=0xa3a11000-0xa3a13000 stackSize=1036KB
 A/art: art/runtime/check_jni.cc:65]   | held mutexes= "mutator lock"(shared held)
 A/art: art/runtime/check_jni.cc:65]   native: #00 pc 00004e64  /system/lib/libbacktrace_libc++.so (UnwindCurrent::Unwind(unsigned int, ucontext*)+23)
 A/art: art/runtime/check_jni.cc:65]   native: #01 pc 00003665  /system/lib/libbacktrace_libc++.so (Backtrace::Unwind(unsigned int, ucontext*)+8)
 A/art: art/runtime/check_jni.cc:65]   native: #02 pc 002423d9  /system/lib/libart.so (art::DumpNativeStack(std::__1::basic_ostream<char, std::__1::char_traits<char> >&, int, char const*, art::mirror::ArtMethod*)+68)
 A/art: art/runtime/check_jni.cc:65]   native: #03 pc 00226013  /system/lib/libart.so (art::Thread::Dump(std::__1::basic_ostream<char, std::__1::char_traits<char> >&) const+146)
 A/art: art/runtime/check_jni.cc:65]   native: #04 pc 000afdcf  /system/lib/libart.so (art::JniAbort(char const*, char const*)+582)
 A/art: art/runtime/check_jni.cc:65]   native: #05 pc 000b050f  /system/lib/libart.so (art::JniAbortF(char const*, char const*, ...)+58)
 A/art: art/runtime/check_jni.cc:65]   native: #06 pc 000b35c7  /system/lib/libart.so (art::ScopedCheck::ScopedCheck(_JNIEnv*, int, char const*)+1286)
 A/art: art/runtime/check_jni.cc:65]   native: #07 pc 000b57f7  /system/lib/libart.so (art::CheckJNI::GetFieldID(_JNIEnv*, _jclass*, char const*, char const*)+26)
 A/art: art/runtime/check_jni.cc:65]   native: #08 pc 00000bc1  /data/app/com.project.kitchen-1/lib/arm/libserialport.so (Java_android_1serialport_1api_SerialPort_close+76)
 A/art: art/runtime/check_jni.cc:65]   native: #09 pc 0000014f  /data/dalvik-cache/arm/data@[email protected]@[email protected] (Java_android_1serialport_1api_SerialPort_close__+82)
 A/art: art/runtime/check_jni.cc:65]   at android_serialport_api.SerialPort.close(Native method)
 A/art: art/runtime/check_jni.cc:65]   at e.a.a.a.a(SerialHelper.java:60)
 A/art: art/runtime/check_jni.cc:65]   at b.d.a.b.a.a(SerialManager.java:80)

解决办法:

proguard-rules.pro添加

-keep class tp.xmaihh.serialport.**{*;}
-keep class android_serialport_api.**{*;}
@xmaihh xmaihh pinned this issue Dec 25, 2019
@xmaihh xmaihh closed this as completed Jan 14, 2020
@xuzhuang1996
Copy link

你是对的。proguard-rules.pro中必须添加出问题的类的全名称。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants