ProGuard: Cannot find reference class com.google.android.gms.R

After some updates in the Android SDK manager, I will try to make a signed apk and get the following:

ProGuard: [] Warning: com.google.android.gms.auth.GoogleAuthUtil: can't find referenced class com.google.android.gms.R ProGuard: [] Warning: com.google.android.gms.auth.GoogleAuthUtil: can't find referenced class com.google.android.gms.R$string ... etc. 

If set -dontwarn com.google.android.gms.** compilation is fine. But after starting, I get an error for many reports like this (from many devices):

 Caused by: android.view.InflateException: Binary XML file line #32: Error inflating class com.google.android.gms.common.SignInButton 

Everything is fine on my devices. Before updating, I have no ProGuard warnings, and everything works fine. How to fix it?

+48
android google-play-services proguard
Sep 05 '13 at 22:25
source share
4 answers

Although adding this file to the proguard-project.txt file works, it retains all classes.

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

I prefer this, which makes the apk file size much smaller:

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

Also notice the Google Play Proguard notification: http://developer.android.com/google/play-services/setup.html#Proguard

 -keep class * extends java.util.ListResourceBundle { protected Object[][] getContents(); } -keep public class com.google.android.gms.common.internal.safeparcel.SafeParcelable { public static final *** NULL; } -keepnames @com.google.android.gms.common.annotation.KeepName class * -keepclassmembernames class * { @com.google.android.gms.common.annotation.KeepName *; } -keepnames class * implements android.os.Parcelable { public static final ** CREATOR; } 
+91
Jun 08 '14 at 18:47
source share

You need to ignore how you compile, but you also need to save the class so that it can find it at runtime.

Add these two lines to the proguard configuration file:

 -keep class com.google.android.gms.** { *; } -dontwarn com.google.android.gms.** 
+27
Oct. 15 '13 at 18:08
source share

If you use proguard, you need to keep some GMS (Google Play Services) classes. We hope that they are annotated using @com.google.android.gms.common.annotation.KeepName .

 # Proguard config for project using GMS -keepnames @com.google.android.gms.common.annotation.KeepName class com.google.android.gms.**, com.google.ads.** -keepclassmembernames class com.google.android.gms.**, com.google.ads.** { @com.google.android.gms.common.annotation.KeepName *; } # Called by introspection -keep class com.google.android.gms.**, com.google.ads.** extends java.util.ListResourceBundle { protected java.lang.Object[][] getContents(); } # This keeps the class name as well as the creator field, because the # "safe parcelable" can require them during unmarshalling. -keepnames class com.google.android.gms.**, com.google.ads.** implements android.os.Parcelable { public static final ** CREATOR; } # com.google.android.gms.auth.api.signin.SignInApiOptions$Builder # references these classes but no implementation is provided. -dontnote com.facebook.Session -dontnote com.facebook.FacebookSdk -keepnames class com.facebook.Session {} -keepnames class com.facebook.FacebookSdk {} # android.app.Notification.setLatestEventInfo() was removed in # Marsmallow, but is still referenced (safely) -dontwarn com.google.android.gms.common.GooglePlayServicesUtil 
+1
Sep 26 '16 at 11:19
source share

I ran into a similar problem and eventually found that I had updated the Google Play Services module, but had not added the module to my main module in Android Studio. Adding this to the resolved issues.

0
Nov 07 '13 at 5:19
source share



All Articles