Proguard - Can't find common super class of [com/google/android/gms/d/kl]

廉价感情. 提交于 2019-11-29 16:54:21

Finally I managed to fix the error. As I am not Proguard expert, I may be wrong but this is the workaround I see at the moment.

As I have mentioned in the question, Facebook Audience Network causes the problem with the release build and errors are associated with the GMS Play Service library. According to comment posted by @pedrofsn, Facebook Audience Network uses the Google Play Service Ads library.

I started looking into documentation for the error Can't find common super class of. It says that

A class in one of your program jars or library jars is referring to a class or interface that is missing from the input. The warning lists both the referencing class(es) and the missing referenced class(es). There can be a few reasons, with their own solutions:

As it says the warning lists both the referencing class(es) and the missing referenced class(es), I decided to remove dontwarn just to see the warnings by the Proguard & updated my Proguard Configuration as below

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

-keep class com.facebook.ads.** { *; }

I managed to see all the warnings by Proguard as the screenshot below.

As we can see from the screenshot, google ads library classes cannot find their referenced class com.google.android.gms.common.internal.zzac. My guess is that this class com.google.android.gms.common.internal.zzac should belong to the internal jar of the google ads dependency & that internal jar is probably missing.

So I have manually added the google ads dependency to my app level build.gradle as below

implementation 'com.google.android.gms:play-services-ads:15.0.1' 

And I see I can compile the release build successfully.

I fixed downgrading 'com.google.firebase:firebase-messaging:17.0.0' to 'com.google.firebase:firebase-messaging:15.0.2'

For this to work, I had to uncomment:

buildTypes {
    release {
        //minifyEnabled true
        //shrinkResources true
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}

and add the below to your proguard-rules.pro file:

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

although uncommenting minifyEnabled is not recommended since it removes dead/unused code

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!