Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android 9 Pie crash (com.google.android.gms... ClassNotFoundException)

I have a Unity3D game published on Android, and it have worked well so far. However, the Android Vitals Dashboard is now reporting a lot of crashes. Here's the detailed info:

By Android version: Android 9   4500    100.0%

Stacktrace:

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@[email protected]:2)
  at ls.a (com.google.android.gms.policy_ads_fdr_dynamite@[email protected]:1)
  at lu.a (com.google.android.gms.policy_ads_fdr_dynamite@[email protected]:18)
  at com.google.android.gms.ads.internal.util.ar.a (com.google.android.gms.policy_ads_fdr_dynamite@[email protected]:10)
  at kx.a (com.google.android.gms.policy_ads_fdr_dynamite@[email protected]:7)
  at kx.run (com.google.android.gms.policy_ads_fdr_dynamite@[email protected]: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@[email protected] (100400-239467275):4)
  at java.lang.ClassLoader.loadClass (ClassLoader.java:312)

My AndroidResolverDependencies.xml file:

<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

I've seen a similar thread in Google AdMob's discussion group suggesting to add the following to the AndroidManifest.xml file:

<uses-library android:name="org.apache.http.legacy" android:required="false" />

However:

  1. I'm not sure the problem is caused by any apache-related API.
  2. I'm afraid this will restrict the number of installs in my app since it will be available to a smaller audience in Google Play due to the uses-library declaration.
like image 619
Eduardo Coelho Avatar asked Apr 11 '19 16:04

Eduardo Coelho


1 Answers

As per Behavior changes: apps targeting API level 28+

Apache HTTP client deprecation

With Android 6.0, we removed support for the Apache HTTP client. Beginning with Android 9, that library is removed from the bootclasspath and is not available to apps by default. To continue using the Apache HTTP client, apps that target Android 9 and above can add the following to their AndroidManifest.xml:

<uses-library android:name="org.apache.http.legacy" android:required="false"/>

Note: The android:required="false" attribute is required for apps that have a minimum SDK of 23 or lower, because on devices with API levels lower than 24, the org.apache.http.legacy library is not available. (On those devices, the Apache HTTP classes are available on the bootclasspath.)

As an alternative to using the runtime Apache library, apps can bundle their own version of the org.apache.http library in their APK. If you do this, you must repackage the library (with a utility like Jar Jar) to avoid class compatibility issues with the classes provided in the runtime.

like image 122
Saad Anees Avatar answered Oct 21 '22 09:10

Saad Anees