首先說一下尿扯,安卓應(yīng)該在Debug調(diào)試期間沒有問題求晶,而不同的機型會出現(xiàn)閃退而無法捕捉BUG,這種情況下如果你連接真機任然捕捉不到崩潰原因衷笋,建議你使用BUG捕捉上傳工具芳杏,推薦:騰訊Bugly 地址:(https://bugly.qq.com/v2/index)
下面是騰訊工具捕捉的崩潰日志
XgStat(17067)
SIGABRT
解析原始
1 #00 pc 0002dc4e /apex/com.android.runtime/lib/bionic/libc.so (abort+165) [armeabi-v8]
2 #01 pc 002ae791 /apex/com.android.runtime/lib/libart.so (art::Runtime::Abort(char const)+1684) [armeabi-v8]
3 #02 pc 000024c7 /system/lib/libbase.so (android::base::LogMessage::~LogMessage()+390) [armeabi-v8]
4 #03 pc 002c9693 /apex/com.android.runtime/lib/libart.so (art::JNI::NewObjectArray(_JNIEnv, int, _jclass, _jobject)+1070) [armeabi-v8]
5 #04 pc 002c867b /apex/com.android.runtime/lib/libart.so (art::StackVisitor::GetMethod() const+82) [armeabi-v8]
6 #05 pc 002ec9bd /apex/com.android.runtime/lib/libart.so (art::mirror::Object* art::gc::Heap::AllocObjectWithAllocator<true, true, art::mirror::CopyClassVisitor>(art::Thread, art::ObjPtr<art::mirror::Class>, unsigned int, art::gc::AllocatorType, art::mirror::CopyClassVisitor const&)+740) [armeabi-v8]
7 #06 pc 002c7b67 /apex/com.android.runtime/lib/libart.so (void art::StackVisitor::WalkStack<(art::StackVisitor::CountTransitions)0>(bool)+1086) [armeabi-v8]
8 #07 pc 002df2a7 /apex/com.android.runtime/lib/libart.so (art::Thread::DumpStack(std::__1::basic_ostream<char, std::__1::char_traits<char> >&, bool, BacktraceMap, bool) const+338) [armeabi-v8]
9 #08 pc 002dba73 /apex/com.android.runtime/lib/libart.so (art::Thread::Dump(std::__1::basic_ostream<char, std::__1::char_traits<char> >&, bool, BacktraceMap, bool) const+34) [armeabi-v8]
10 #09 pc 002f43e9 /apex/com.android.runtime/lib/libart.so (art::mirror::String::DoReplace(art::Thread, art::Handle<art::mirror::String>, unsigned short, unsigned short)+912) [armeabi-v8]
11 #10 pc 002eede3 /apex/com.android.runtime/lib/libart.so (art::ThreadList::RunCheckpoint(art::Closure, art::Closure)+354) [armeabi-v8]
12 #11 pc 002ee34f /apex/com.android.runtime/lib/libart.so (art::ThreadList::Dump(std::__1::basic_ostream<char, std::__1::char_traits<char> >&, bool)+1142) [armeabi-v8]
13 #12 pc 002ae51b /apex/com.android.runtime/lib/libart.so (art::Runtime::Abort(char const)+1054) [armeabi-v8]
14 #13 pc 000024c7 /system/lib/libbase.so (android::base::LogMessage::~LogMessage()+390) [armeabi-v8]
15 #14 pc 002c9693 /apex/com.android.runtime/lib/libart.so (art::JNI::NewObjectArray(_JNIEnv, int, _jclass, _jobject)+1070) [armeabi-v8]
16 #15 pc 00337d65 /apex/com.android.runtime/lib/libart.so (art::OatFileManager::DumpForSigQuit(std::__1::basic_ostream<char, std::__1::char_traits<char> >&)+60) [armeabi-v8]
17 #16 pc 00337fd3 /apex/com.android.runtime/lib/libart.so (art::GetCalleeSaveMethodCallerAndOuterMethod(art::Thread*, art::CalleeSaveType)+346) [armeabi-v8]
18 #17 pc 00346ae9 /apex/com.android.runtime/lib/libart.so (artResolveTypeFromCode+28) [armeabi-v8]
19 #18 pc 00008f8f /apex/com.android.runtime/lib/libart.so [armeabi-v8]
20 #19 pc 00032553 /system/framework/oat/arm/org.apache.http.legacy.odex [armeabi]
21 java:
22 [Failed to get Java stack]
騰訊工具給出的異常分析及定位:
通過上面描述,應(yīng)該是騰訊信鴿的.so JNI調(diào)用問題辟宗,嘗試解決方案就是更新第三方包爵赵,重新搭建或者完善最新三方包的資源,應(yīng)該隨著手機系統(tǒng)版本的更新迭代泊脐,很多機型適配都是問題空幻,如果你用的是大廠三方包問題,不需要你去解決底層容客,只需要緊更開發(fā)文檔秕铛,及時更新工具包即可则剃,嘗試更新之后發(fā)現(xiàn)崩潰解決了!
所以如捅,當(dāng)你不知道一個BUG崩潰原因棍现,你可以嘗試一下這個解決思路,只是提供參考镜遣!
不過引發(fā)了一個新的問題己肮,Andriod 9 或者P 版本系統(tǒng),對http請求有攔截問題
communication to ... not permitted by network security policy
解決方法:
如果你的應(yīng)用加了信鴿推送的 Andriod P 兼容方案悲关,那么你只需要在下面添加:
<base-config cleartextTrafficPermitted ="true" />
2.清單文件添加:
加上下面這個就行谎僻,位置看圖,
android:networkSecurityConfig="@xml/xg_network_security_config"
tools:ignore="GoogleAppIndexingWarning"
tools:replace="android:networkSecurityConfig">
如果你的tools:replace 原本已經(jīng)存在寓辱,直接添加下面這樣 艘绍,用“,”分割秫筏,后面添加就好
tools:replace="android:theme,android:allowBackup,android:name,android:icon,android:networkSecurityConfig">
3.添加這個
<uses-library android:name="org.apache.http.legacy" android:required="false"/>
4.如何你的編譯不通過诱鞠,試試這樣:
編譯APK時使用compileSdkVersion和targetSdkVersion都使用28