ProGuard:找不到引用的类 com.google.android.gms.R [英] ProGuard: can't find referenced class com.google.android.gms.R

查看:34
本文介绍了ProGuard:找不到引用的类 com.google.android.gms.R的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 Android SDK 管理器中进行一些更新后,我尝试制作签名的 apk 并得到这个:

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.

如果设置 -dontwarn com.google.android.gms.** 编译就可以了.但是运行后我收到很多这样的错误报告(来自许多设备):

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

在我的设备上一切正常.在更新之前,我没有 ProGuard 警告并且一切正常.怎么解决的?

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

推荐答案

虽然将这个添加到 proguard-project.txt 文件有效,但它保留了所有类.

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

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

我更喜欢这个,这使得 apk 文件大小更小:

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

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

还要注意此处的最新 Google Play Proguard 通知:http://developer.android.com/google/play-services/setup.html#Proguard

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;
}

这篇关于ProGuard:找不到引用的类 com.google.android.gms.R的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆