Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
430 views
in Technique[技术] by (71.8m points)

ProGuard: can't find referenced class com.google.android.gms.R

After some updates in Android SDK manager I try make signed apk and get this:

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.** compiling is OK. But after run I get error 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

On my devices all ok. Before update I have not ProGuard warnings and all work perfectly. How it fix?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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

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

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

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

Also note up to date Google Play Proguard notification here: 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;
}

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

2.1m questions

2.1m answers

60 comments

57.0k users

...