GOOGLE PLAY SERVICES EXCEPTION: com.google.android

2019-09-08 02:40发布

问题:

I am trying to integrate Google Play Games into my app. It is currently working in debug mode. However, it does not seem to work in release mode. I am getting errors. I tried clean and rebuild.

java.lang.RuntimeException: Unable to get provider com.google.android.gms.measurement.AppMeasurementContentProvider: java.lang.ClassNotFoundException

And then this one:

GOOGLE PLAY SERVICES EXCEPTION: com.google.android.gms.common.GooglePlayServicesUtil

Followed by this one:

There is a problem with the Google Play Services library, which is required for Android Advertising ID support. The Google Play Services library should be integrated in any app shipping in the Play Store that uses analytics or advertising.

What could be wrong? I tried experimenting with Gradle, but no luck yet.

If I disable Proguard, it works! This seems to be a known issue, but not resolved yet. Any ideas?

回答1:

The problem was that in my Gradle I was using

classpath 'com.google.gms:google-services:1.5.0-beta2'

Now I am using

classpath 'com.google.gms:google-services:1.5.0'


回答2:

add below code in your proguard-rule.pro and try to regenerate APK

-dontwarn com.google.android.gms.**
-keep class com.google.android.gms.**{ *; }
-keep interface com.google.android.gms.** { *; }