生成APK时的前卫配置错误

时间:2019-04-23 06:16:55

标签: android apk proguard obfuscation android-proguard

在申请保镖时遇到此错误

Unexpected error while performing partial evaluation:
  Class       = [com/google/android/gms/ads/AdLoader$Builder]
  Method      = [forPublisherAdView(Lcom/google/android/gms/ads/formats/OnPublisherAdViewLoadedListener;[Lcom/google/android/gms/ads/AdSize;)Lcom/google/android/gms/ads/AdLoader$Builder;]
  Exception   = [java.lang.IllegalArgumentException] (Can't find common super class of [com/google/android/gms/internal/zzko] (with 1 known super classes) and [android/os/RemoteException] (with 5 known super classes))
Unexpected error while preverifying:
  Class       = [com/google/android/gms/ads/AdLoader$Builder]
  Method      = [forPublisherAdView(Lcom/google/android/gms/ads/formats/OnPublisherAdViewLoadedListener;[Lcom/google/android/gms/ads/AdSize;)Lcom/google/android/gms/ads/AdLoader$Builder;]
  Exception   = [java.lang.IllegalArgumentException] (Can't find common super class of [com/google/android/gms/internal/zzko] (with 1 known super classes) and [android/os/RemoteException] (with 5 known super classes))

同时生成签名的APK。我检查了一些问题和答案,但这没有帮助。

proguard-rules.pro

-ignorewarnings

-keep class * {
    public private *;
}

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

2 个答案:

答案 0 :(得分:0)

带有includedescriptorclasses的配置规则应保留它:

-keep,includedescriptorclasses class com.google.android.gms.** { *; }
-keep,includedescriptorclasses class com.google.android.gms.internal.** { *; }
-keep,includedescriptorclasses class com.google.android.gms.ads.** { *; }

同时保留private方法会打乱混淆的想法:

-keep class * {public private *;}

答案 1 :(得分:0)

我有解决办法。

应用pro-guard后,它并没有显示确切的错误,但是经过更多的努力后,它显示了实际错误,并且如果删除pro-guard,则显示没有错误。

此错误是由于一些资源丢失造成的,因为我估计是在构建期间从缓存中获取的。