简体   繁体   中英

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

In our project we have been using successfully:

  • Firebase (for FCM)
  • Crashlytics (for reporting crashes)
  • Proguard (optimized version)

All was going fine until last week, when we upgraded to gradle plugin 3.2.0 .

In this version, if we have the following proguard configuration to remove calls to Log:

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

when running the app, we get:

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$1 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)`

If we remove that config to strip the calls to Log all is fine, as it was in the previous version of the gradle plugin (3.1.4).

Does anyone have an idea on what might be causing this?

Seems like there is some problem with proguard -assumenosideeffects and Log .

Try using -assumenosideffects only on the methods you use and whichever methods that depend on those Log methods.

Something like:

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

instead of the usual

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

Hope this helps.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM