pro-guard configuration error while generating APK

218 Views Asked by At

Getting this error while applying pro-guard

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))

While generating signed apk. I have checked some of questions and answers but it doest help.

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

There are 2 best solutions below

0
Amit Vaghela On BEST ANSWER

I got solution.

After applying pro-guard, it was not showing me exact error but after more efforts it shows actual error and if remove pro-guard than there was no error.

This error was due to some missing resources as during build it is taking from cache i guess.

3
Martin Zeitler On

A configuration rule with includedescriptorclasses should keep it:

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

While keeping private methods defeats the idea of obfuscation:

-keep class * {public private *;}