Proguard 未解析的类引用
Posted
技术标签:
【中文标题】Proguard 未解析的类引用【英文标题】:Proguard unresolved references to classes 【发布时间】:2017-08-20 09:32:50 【问题描述】:在使用 Proguard 构建 apk 时,我看到了这些警告:
com.google.android.gms.internal.zzaq: can't find referenced class com.google.android.gms.internal.zzzk
com.google.android.gms.internal.zzaq: can't find referenced class com.google.android.gms.internal.zzzk$zza
com.google.android.gms.internal.zzaq: can't find referenced class com.google.android.gms.internal.zzzk
com.google.android.gms.internal.zzaq: can't find referenced class com.google.android.gms.internal.zzzk$zza
com.google.android.gms.internal.zzaq: can't find referenced class com.google.android.gms.internal.zzzk$zza
com.google.android.gms.internal.zzaq: can't find referenced class com.google.android.gms.internal.zzzk$zza
com.google.android.gms.internal.zzaq: can't find referenced class com.google.android.gms.internal.zzzk
com.google.android.gms.internal.zzaq$1: can't find referenced class com.google.android.gms.internal.zzzk
com.google.android.gms.internal.zzaq$1: can't find referenced class com.google.android.gms.internal.zzzk
com.google.android.gms.internal.zzbd: can't find referenced class com.google.android.gms.internal.zzaqg
com.google.android.gms.internal.zzbd: can't find referenced class com.google.android.gms.internal.zzzk
com.google.android.gms.internal.zzbd: can't find referenced class com.google.android.gms.internal.zzzk
com.google.android.gms.internal.zzbd: can't find referenced class com.google.android.gms.internal.zzaqg
com.google.android.gms.internal.zzej: can't find referenced field 'int[] AdsAttrs' in program class com.google.android.gms.R$styleable
com.google.android.gms.internal.zzej: can't find referenced field 'int AdsAttrs_adSize' in program class com.google.android.gms.R$styleable
com.google.android.gms.internal.zzej: can't find referenced field 'int AdsAttrs_adSizes' in program class com.google.android.gms.R$styleable
com.google.android.gms.internal.zzej: can't find referenced field 'int AdsAttrs_adUnitId' in program class com.google.android.gms.R$styleable
我正在使用 Google Play Services 10.2.0,模块 ads、ads-lite、analytics、analytics-impl、base、basement、drive、games、tasks。
需要包含哪些模块或库来修复这些警告?
【问题讨论】:
【参考方案1】:基于这个thread,如果你使用ProGuard,你需要保留一些GMS(Google Play Services)类,并用@com.google.android.gms.common.annotation.KeepName
注解。
您需要像编译一样忽略,但您还需要保留该类,以便它可以在运行时找到它。
将这两行添加到您的 proguard 配置文件中:
-keep class com.google.android.gms.** *; -dontwarn com.google.android.gms.**
您还可以查看这些相关的 SO 帖子:
Proguard and error com.google.android.gms.internal.zzhu: can't find referenced class android.security.NetworkSecurityPolicy How to use -dontwarn in ProGuard?【讨论】:
以上是关于Proguard 未解析的类引用的主要内容,如果未能解决你的问题,请参考以下文章