我无法创建发布版本。突然,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受众群体网络依赖关系可修复错误。不幸的是,我不能永久地从项目中做到这一点。
请帮我确定问题的原因。提前谢谢。
答案 0 :(得分:3)
最后我设法修复了错误。由于我不是Proguard专家,我可能错了,但这是我目前看到的解决方法。
正如我在问题中所提到的,Facebook Audience Network会导致发布版本出现问题,并且错误与GMS Play Service库相关联。根据@pedrofsn发布的comment,Facebook Audience Network使用Google Play服务广告库。
我开始调查documentation错误Can't find common super class of
。它说
您的某个程序罐或库罐中的类指的是a 输入中缺少的类或接口。警告列表 引用类和缺少引用的类(es)。 可以有几个原因,有自己的解决方案:
正如它所说的警告列出了引用类和缺少的引用类(es),我决定删除dontwarn
只是为了看到Proguard&的警告。更新了我的Proguard配置,如下所示
-keep public class com.google.android.gms.* { public *; }
-keep class com.facebook.ads.** { *; }
我设法将Proguard的所有警告视为下面的截图。
从屏幕截图中我们可以看到,Google广告图书馆类无法找到他们引用的类com.google.android.gms.common.internal.zzac
。我猜这个类com.google.android.gms.common.internal.zzac
应该属于google ads依赖关系&那个内部罐子可能不见了。
因此,我已将Google广告相关性手动添加到我的应用级build.gradle
,如下所示
implementation 'com.google.android.gms:play-services-ads:15.0.1'
我发现我可以成功编译发布版本。
答案 1 :(得分:0)
我修正了降级&com; google.firebase:firebase-messaging:17.0.0'到#com.google.firebase:firebase-messaging:15.0.2'
答案 2 :(得分:0)
为此,我不得不取消评论:
buildTypes {
release {
//minifyEnabled true
//shrinkResources true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
并将以下内容添加到您的proguard-rules.pro文件中:
-keep class com.google.android.gms.internal.** { *; }
-keep public class com.google.android.gms.* { public *; }
-dontwarn com.google.android.gms.**
尽管建议不要注释minifyEnabled
,因为它会删除无效/未使用的代码