我无法创建发布版本。 Android Studio 突然开始抛出以下错误。
Unexpected error while performing partial evaluation:
Class = [com/google/android/gms/d/lc]
Method = [a(Lcom/google/android/gms/d/kk;Landroid/content/Context;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Lcom/google/android/gms/d/lh;Lcom/google/android/gms/d/en;Lcom/google/android/gms/d/lb;)Lcom/google/android/gms/d/kn;]
Exception = [java.lang.IllegalArgumentException] (Can't find common super class of [com/google/android/gms/d/kn] (with 1 known super classes) and [java/lang/String] (with 2 known super classes))
Unexpected error while preverifying:
Class = [com/google/android/gms/d/lc]
Method = [a(Lcom/google/android/gms/d/kk;Landroid/content/Context;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Lcom/google/android/gms/d/lh;Lcom/google/android/gms/d/en;Lcom/google/android/gms/d/lb;)Lcom/google/android/gms/d/kn;]
Exception = [java.lang.IllegalArgumentException] (Can't find common super class of [com/google/android/gms/d/kn] (with 1 known super classes) and [java/lang/String] (with 2 known super classes))
Warning: Exception while processing task java.io.IOException: java.lang.IllegalArgumentException: Can't find common super class of [com/google/android/gms/d/kn] (with 1 known super classes) and [java/lang/String] (with 2 known super classes)
这是我的 Proguard 配置
-keep public class com.google.android.gms.* { public *; }
-dontwarn com.google.android.gms.**
-keep class com.facebook.ads.** { *; }
这是我项目的gradle依赖列表
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
androidTestImplementation('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
implementation 'com.android.support.constraint:constraint-layout:1.1.0'
implementation 'com.android.support:design:27.1.1'
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support:cardview-v7:27.1.1'
implementation 'com.google.firebase:firebase-perf:16.0.0'
implementation 'com.google.firebase:firebase-config:16.0.0'
implementation 'com.google.firebase:firebase-core:16.0.0'
implementation 'com.google.firebase:firebase-messaging:17.0.0'
implementation 'com.google.android.gms:play-services-analytics:16.0.0'
implementation 'com.google.android.gms:play-services-drive:15.0.1'
implementation 'com.google.android.gms:play-services-auth:15.0.1'
implementation 'com.startapp:inapp-sdk:3.8.4'
implementation 'com.facebook.android:audience-network-sdk:4.28.2'
testImplementation 'junit:junit:4.12'
testImplementation 'org.mockito:mockito-core:2.7.1'
testImplementation 'org.powermock:powermock-mockito-release-full:1.4.9'
implementation('com.crashlytics.sdk.android:crashlytics:2.9.1@aar') {
transitive = true
}
}
注意 评论 Facebook 受众网络依赖项可以修复错误。不幸的是,我不能从项目中永久地做到这一点。
请帮我找出问题的原因。提前致谢。
最佳答案
最后我设法修复了错误。由于我不是 Proguard 专家,我可能是错的,但这是我目前看到的解决方法。
正如我在问题中提到的,Facebook Audience Network 导致发布版本出现问题,并且错误与 GMS Play 服务库相关。根据comment由@pedrofsn 发布,Facebook Audience Network 使用Google Play 服务广告库。
我开始研究 documentation对于错误 Can't find common super class of
。据说
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:
正如它所说,警告列出了引用类和缺少的引用类,我决定删除 dontwarn
只是为了查看 Proguard 的警告并更新了我的 Proguard 配置如下
-keep public class com.google.android.gms.* { public *; }
-keep class com.facebook.ads.** { *; }
我成功地看到了 Proguard 的所有警告,如下图所示。
从截图中我们可以看出,谷歌广告库类无法找到它们引用的类com.google.android.gms.common.internal.zzac
。我的猜测是此类 com.google.android.gms.common.internal.zzac
应该属于 google ads 依赖项的内部 jar,并且该内部 jar 可能丢失了。
所以我手动将谷歌广告依赖项添加到我的应用级别 build.gradle
如下
implementation 'com.google.android.gms:play-services-ads:15.0.1'
而且我看到我可以成功编译发布版本。
关于android - Proguard - 找不到 [com/google/android/gms/d/kl] 的通用父类(super class),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50583150/