Android 应用程序在模拟器中启动时崩溃
Posted
技术标签:
【中文标题】Android 应用程序在模拟器中启动时崩溃【英文标题】:Android App is crashing on launch in the emulator 【发布时间】:2022-01-06 21:19:45 【问题描述】:我的应用程序在实际设备中运行良好,因为它在模拟器中启动时崩溃。下面是日志。
E/FirebaseInstanceId: Failed to get FIS auth token
java.util.concurrent.ExecutionException: javax.net.ssl.SSLHandshakeException: Unacceptable certificate: EMAILADDRESS=certadmin@netskope.com, CN=caadmin.netskope.com, O=netSkope Inc, L=London, ST=London, C=GB
at com.google.android.gms.tasks.Tasks.zzb(Unknown Source:61)
at com.google.android.gms.tasks.Tasks.await(Unknown Source:23)
at com.google.firebase.iid.GmsRpc.setDefaultAttributesToBundle(com.google.firebase:firebase-iid@@20.2.3:55)
at com.google.firebase.iid.GmsRpc.startRpc(com.google.firebase:firebase-iid@@20.2.3:37)
at com.google.firebase.iid.GmsRpc.getToken(com.google.firebase:firebase-iid@@20.2.3:13)
at com.google.firebase.iid.FirebaseInstanceId.lambda$getInstanceId$2$FirebaseInstanceId(com.google.firebase:firebase-iid@@20.2.3:164)
at com.google.firebase.iid.FirebaseInstanceId$$Lambda$4.start(Unknown Source:8)
at com.google.firebase.iid.RequestDeduplicator.getOrStartGetTokenRequest(com.google.firebase:firebase-iid@@20.2.3:14)
at com.google.firebase.iid.FirebaseInstanceId.lambda$getInstanceId$3$FirebaseInstanceId(com.google.firebase:firebase-iid@@20.2.3:163)
at com.google.firebase.iid.FirebaseInstanceId$$Lambda$1.then(Unknown Source:6)
at com.google.android.gms.tasks.zzf.run(Unknown Source:2)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
at com.google.android.gms.common.util.concurrent.zza.run(Unknown Source:6)
at java.lang.Thread.run(Thread.java:919)
Caused by: javax.net.ssl.SSLHandshakeException: Unacceptable certificate: EMAILADDRESS=certadmin@netskope.com, CN=caadmin.netskope.com, O=netSkope Inc, L=London, ST=London, C=GB
at com.android.org.conscrypt.ConscryptFileDescriptorSocket.startHandshake(ConscryptFileDescriptorSocket.java:231)
【问题讨论】:
【参考方案1】:每个应用都必须明确添加用户定义的证书:
res/xml/network_security_config.xml
<network-security-config>
<base-config>
<trust-anchors>
<certificates src="system"/>
<certificates src="user"/>
</trust-anchors>
</base-config>
</network-security-config>
还要确保 AndroidManifest.xml 在标签中包含 android:networkSecurityConfig 属性:
<?xml version="1.0" encoding="utf-8"?>
<manifest ... >
<application android:networkSecurityConfig="@xml/network_security_config"
... >
...
</application>
</manifest>
【讨论】:
以上是关于Android 应用程序在模拟器中启动时崩溃的主要内容,如果未能解决你的问题,请参考以下文章
应用程序在启动时崩溃-android.view.InflateException:二进制XML文件行#0:二进制XML
Xamarin安卓应用程序在启动时与BroadcastReceiver崩溃但是启动了吗?
Flutter Android TV 应用程序被拒绝,因为“启动后崩溃”,但它在模拟器和 android 电视上正常工作。你有啥建议吗?