Android 9 Pie崩溃(com.google.android.gms ... ClassNotFoundException)

满堂花醉三千客,一剑霜寒十四洲。这篇文章主要讲述Android 9 Pie崩溃(com.google.android.gms ... ClassNotFoundException)相关的知识,希望能为你提供帮助。
我在android上发布了Unity3D游戏,到目前为止它运行良好。但是,Android Vitals Dashboard现在报告了很多崩溃事件。这是详细信息:

By Android version: Android 94500100.0%

堆栈跟踪:
java.lang.Error: FATAL EXCEPTION [Thread-360] Unity version: 2017.3.1p3 Device model: Google Pixel Device fingerprint: google/sailfish/sailfish:9/PQ2A.190305.002/5240760:user/release-keys Caused by at lt.b (com.google.android.gms.policy_ads_fdr_dynamite@30000@30000.238272502.238272502:2) at ls.a (com.google.android.gms.policy_ads_fdr_dynamite@30000@30000.238272502.238272502:1) at lu.a (com.google.android.gms.policy_ads_fdr_dynamite@30000@30000.238272502.238272502:18) at com.google.android.gms.ads.internal.util.ar.a (com.google.android.gms.policy_ads_fdr_dynamite@30000@30000.238272502.238272502:10) at kx.a (com.google.android.gms.policy_ads_fdr_dynamite@30000@30000.238272502.238272502:7) at kx.run (com.google.android.gms.policy_ads_fdr_dynamite@30000@30000.238272502.238272502:2) Caused by: java.lang.ClassNotFoundException: at dalvik.system.BaseDexClassLoader.findClass (BaseDexClassLoader.java:134) at java.lang.ClassLoader.loadClass (ClassLoader.java:379) at ac.loadClass (com.google.android.gms.dynamite_dynamiteloader@16089081@16.0.89 (100400-239467275):4) at java.lang.ClassLoader.loadClass (ClassLoader.java:312)

我的AndroidResolverDependencies.xml文件:
< dependencies> < packages> < package> com.android.support:customtabs:[26.0.0, 27.2.0[< /package> < package> com.android.support:support-v4:[26.0.0, 27.2.0[< /package> < package> com.google.android.gms:play-services-ads:17.2.0< /package> < package> com.google.android.gms:play-services-analytics:11.8.0< /package> < package> com.google.android.gms:play-services-base:[10.2.1, 12.1.0[< /package> < package> com.google.android.gms:play-services-location:[10.2.1, 12.1.0[< /package> < package> com.google.firebase:firebase-messaging:[10.2.1, 12.1.0[< /package> < /packages> < files> < file> Assets/Plugins/Android/android.arch.core.common-1.1.0.jar< /file> < file> Assets/Plugins/Android/android.arch.core.runtime-1.1.0.aar< /file> < file> Assets/Plugins/Android/android.arch.lifecycle.common-1.1.0.jar< /file> < file> Assets/Plugins/Android/android.arch.lifecycle.livedata-core-1.1.0.aar< /file> < file> Assets/Plugins/Android/android.arch.lifecycle.runtime-1.1.0.aar< /file> < file> Assets/Plugins/Android/android.arch.lifecycle.viewmodel-1.1.0.aar< /file> < file> Assets/Plugins/Android/com.android.support.customtabs-27.1.1.aar< /file> < file> Assets/Plugins/Android/com.android.support.support-annotations-27.1.1.jar< /file> < file> Assets/Plugins/Android/com.android.support.support-compat-27.1.1.aar< /file> < file> Assets/Plugins/Android/com.android.support.support-core-ui-27.1.1.aar< /file> < file> Assets/Plugins/Android/com.android.support.support-core-utils-27.1.1.aar< /file> < file> Assets/Plugins/Android/com.android.support.support-fragment-27.1.1.aar< /file> < file> Assets/Plugins/Android/com.android.support.support-media-compat-27.1.1.aar< /file> < file> Assets/Plugins/Android/com.android.support.support-v4-27.1.1.aar< /file> < file> Assets/Plugins/Android/com.google.android.gms.play-services-ads-17.2.0.aar< /file> < file> Assets/Plugins/Android/com.google.android.gms.play-services-ads-base-17.2.0.aar< /file> < file> Assets/Plugins/Android/com.google.android.gms.play-services-ads-identifier-16.0.0.aar< /file> < file> Assets/Plugins/Android/com.google.android.gms.play-services-ads-lite-17.2.0.aar< /file> < file> Assets/Plugins/Android/com.google.android.gms.play-services-analytics-16.0.8.aar< /file> < file> Assets/Plugins/Android/com.google.android.gms.play-services-analytics-impl-16.0.8.aar< /file> < file> Assets/Plugins/Android/com.google.android.gms.play-services-base-16.1.0.aar< /file> < file> Assets/Plugins/Android/com.google.android.gms.play-services-basement-16.2.0.aar< /file> < file> Assets/Plugins/Android/com.google.android.gms.play-services-gass-17.2.0.aar< /file> < file> Assets/Plugins/Android/com.google.android.gms.play-services-location-16.0.0.aar< /file> < file> Assets/Plugins/Android/com.google.android.gms.play-services-measurement-base-16.3.0.aar< /file> < file> Assets/Plugins/Android/com.google.android.gms.play-services-measurement-sdk-api-16.3.0.aar< /file> < file> Assets/Plugins/Android/com.google.android.gms.play-services-places-placereport-16.0.0.aar< /file> < file> Assets/Plugins/Android/com.google.android.gms.play-services-stats-16.0.1.aar< /file> < file> Assets/Plugins/Android/com.google.android.gms.play-services-tagmanager-v4-impl-16.0.8.aar< /file> < file> Assets/Plugins/Android/com.google.android.gms.play-services-tasks-16.0.1.aar< /file> < file> Assets/Plugins/Android/com.google.auto.value.auto-value-annotations-1.6.jar< /file> < file> Assets/Plugins/Android/com.google.firebase.firebase-common-16.1.0.aar< /file> < file> Assets/Plugins/Android/com.google.firebase.firebase-iid-17.1.2.aar< /file> < file> Assets/Plugins/Android/com.google.firebase.firebase-iid-interop-16.0.1.aar< /file> < file> Assets/Plugins/Android/com.google.firebase.firebase-measurement-connector-17.0.1.aar< /file> < file> Assets/Plugins/Android/com.google.firebase.firebase-messaging-17.6.0.aar< /file> < /files> < /dependencies>

Target API level: 28 Minimum API level: 16

我在Google AdMob's discussion group中看到过类似的线程,建议将以下内容添加到AndroidManifest.xml文件中:
< uses-library android:name="org.apache.http.legacy" android:required="false" />

然而:
  1. 我不确定问题是由任何与apache相关的API引起的。
  2. 我担心这会限制我的应用中的安装次数,因为由于uses-library声明,它可供Google Play中的较小受众使用。
答案根据Behavior changes: apps targeting API level 28+
Apache HTTP客户端弃用
【Android 9 Pie崩溃(com.google.android.gms ... ClassNotFoundException)】在Android 6.0中,我们删除了对Apache HTTP客户端的支持。从Android 9开始,该库将从bootclasspath中删除,默认情况下不可用于应用程序。要继续使用Apache HTTP客户端,针对Android 9及更高版本的应用可以将以下内容添加到其AndroidManifest.xml
< uses-library android:name="org.apache.http.legacy" android:required="false"/>

注意:最低SDK为23或更低的应用程序需要android:required =“false”属性,因为在API级别低于24的设备上,org.apache.http.legacy库不可用。 (在这些设备上,Apache HTTP类在bootclasspath上可用。)
作为使用运行时Apache库的替代方法,应用程序可以在其APK中捆绑自己版本的org.apache.http库。如果这样做,则必须重新打包库(使用Jar Jar之类的实用程序)以避免与运行时中提供的类的类兼容性问题。

    推荐阅读