VerifyError: Verifier rejected class com.google.firebase.FirebaseApp using Gradle Plugin 3.2.0 + Proguard to strip logs

VerifyError: Verifier rejected class com.google.firebase.FirebaseApp using Gradle Plugin 3.2.0 + Proguard to strip logs

在我们的项目中一直使用成功:

一切都很好,直到上周我们升级到 gradle plugin 3.2.0

在这个版本中,如果我们有以下proguard配置来移除对Log的调用:

-assumenosideeffects class android.util.Log { *; }

当 运行 应用时,我们得到:

java.lang.VerifyError: Verifier rejected class com.google.firebase.FirebaseApp: void com.google.firebase.FirebaseApp.() failed to verify: void com.google.firebase.FirebaseApp.(): [0x37] register v0 has type Uninitialized Reference: java.lang.Object Allocation PC: 53 but expected Reference: java.lang.Object void com.google.firebase.FirebaseApp.(android.content.Context, java.lang.String, com.google.firebase.b) failed to verify: void com.google.firebase.FirebaseApp.(android.content.Context, java.lang.String, com.google.firebase.b): [0x3C] register v8 has type Uninitialized Reference: com.google.firebase.internal.a Allocation PC: 58 but expected Reference: com.google.firebase.FirebaseApp$a com.google.firebase.FirebaseApp com.google.firebase.FirebaseApp.a(android.content.Context, com.google.firebase.b, java.lang.String) failed to verify: com.google.firebase.FirebaseApp com.google.firebase.FirebaseApp.a(android.content.Context, com.google.firebase.b, java.lang.String): [0x17] register v1 has type Uninitialized Reference: com.google.firebase.FirebaseApp Allocation PC: 21 but expected Reference: com.google.android.gms.common.api.internal.a$a (declaration of 'com.google.firebase.FirebaseApp' appears in /data/app/com.example.app-2/base.apk)`

如果我们删除该配置以去除对 Log 的调用,一切都很好,就像在以前版本的 gradle 插件中一样( 3.1.4).

有人知道是什么原因造成的吗?

proguard -assumenosideeffectsLog 似乎有问题。

尝试仅对您使用的方法以及依赖于这些 Log 方法的任何方法使用 -assumenosideffects

类似于:

-assumenosideeffects class android.util.Log {
    public static *** v(...);
    public static *** d(...);
    public static *** i(...);
    public static *** w(...);
    public static *** e(...);
}

而不是通常的

-assumenosideeffects class android.util.Log {*;}

希望这对您有所帮助。