首先说一下,安卓应该在Debug调试期间没有问题,而不同的机型会出现闪退而无法捕捉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]
腾讯工具给出的异常分析及定位:
通过上面描述,应该是腾讯信鸽的.so JNI调用问题,尝试解决方案就是更新第三方包,重新搭建或者完善最新三方包的资源,应该随着手机系统版本的更新迭代,很多机型适配都是问题,如果你用的是大厂三方包问题,不需要你去解决底层,只需要紧更开发文档,及时更新工具包即可,尝试更新之后发现崩溃解决了!
所以,当你不知道一个BUG崩溃原因,你可以尝试一下这个解决思路,只是提供参考!
不过引发了一个新的问题,Andriod 9 或者P 版本系统,对http请求有拦截问题
communication to ... not permitted by network security policy
解决方法:
如果你的应用加了信鸽推送的 Andriod P 兼容方案,那么你只需要在下面添加:
<base-config cleartextTrafficPermitted ="true" />
2.清单文件添加:
加上下面这个就行,位置看图,
android:networkSecurityConfig="@xml/xg_network_security_config"
tools:ignore="GoogleAppIndexingWarning"
tools:replace="android:networkSecurityConfig">
如果你的tools:replace 原本已经存在,直接添加下面这样 ,用“,”分割,后面添加就好
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