com.google.android.gms.internal.firebase-perf.zza 中缺少方法

Missing method in com.google.android.gms.internal.firebase-perf.zza

此错误仅在 minifyEnabled true 时出现,所以我怀疑问题与 proguard 或 R8 有关

错误

2019-08-22 18:26:05.320 8403-8403/com.xxxx.xxxx
E/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.easyschool.easyschoolwebsite, PID: 8403
    java.lang.ExceptionInInitializerError
        at com.google.firebase.perf.provider.FirebasePerfProvider.<init>(com.google.firebase:firebase-perf@@19.0.0:2)
        at java.lang.Class.newInstance(Native Method)
        at android.app.AppComponentFactory.instantiateProvider(AppComponentFactory.java:121)
        at androidx.core.app.CoreComponentFactory.instantiateProvider(CoreComponentFactory.java:60)
        at android.app.ActivityThread.installProvider(ActivityThread.java:6405)
        at android.app.ActivityThread.installContentProviders(ActivityThread.java:5963)
        at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5869)
        at android.app.ActivityThread.access00(ActivityThread.java:200)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1653)
        at android.os.Handler.dispatchMessage(Handler.java:106)
        at android.os.Looper.loop(Looper.java:193)
        at android.app.ActivityThread.main(ActivityThread.java:6694)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
     Caused by: java.lang.RuntimeException: Shaking error: Missing method in com.google.android.gms.internal.firebase-perf.zza: void <clinit>()
        at com.google.android.gms.internal.firebase-perf.zza.<clinit>(Unknown Source:9)
        at com.google.firebase.perf.provider.FirebasePerfProvider.<init>(com.google.firebase:firebase-perf@@19.0.0:2) 
        at java.lang.Class.newInstance(Native Method) 
        at android.app.AppComponentFactory.instantiateProvider(AppComponentFactory.java:121) 
        at androidx.core.app.CoreComponentFactory.instantiateProvider(CoreComponentFactory.java:60) 
        at android.app.ActivityThread.installProvider(ActivityThread.java:6405) 
        at android.app.ActivityThread.installContentProviders(ActivityThread.java:5963) 
        at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5869) 
        at android.app.ActivityThread.access00(ActivityThread.java:200) 
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1653) 
        at android.os.Handler.dispatchMessage(Handler.java:106) 
        at android.os.Looper.loop(Looper.java:193) 
        at android.app.ActivityThread.main(ActivityThread.java:6694) 
        at java.lang.reflect.Method.invoke(Native Method) 
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493) 
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858) 

gradle

apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'
apply plugin: 'com.google.firebase.firebase-perf'
apply plugin: 'io.fabric'

android {
    signingConfigs {
        release {
            storeFile file('xxxxxx/Keygen.jks')
            storePassword 'xxxxxxx'
            keyAlias = 'myandroidkey'
            keyPassword 'xxxxxxxxx'
        }
    }
    compileSdkVersion 28
    defaultConfig {
        applicationId "com.easyschool.easyschoolwebsite"
        minSdkVersion 21
        targetSdkVersion 28
        versionCode 46
        versionName "32.8.5"
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
        vectorDrawables.useSupportLibrary = true

        manifestPlaceholders = [
                onesignal_app_id : 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',
                // Project number pulled from dashboard, local value is ignored.
                onesignal_google_project_number: 'REMOTE'
        ]
    }


    buildTypes {
        release {
            minifyEnabled false
            shrinkResources false

            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'

            buildConfigField "String", "SERVER_URL", '"https://xxx/xx"'
            buildConfigField "String", "Share_URL", '"xxx/xx/"'

        }
        debug {
            minifyEnabled true
            shrinkResources false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules-debug.pro'

//            signingConfig signingConfigs.release

           buildConfigField "String", "SERVER_URL", '"https://xxx/xx"'
            buildConfigField "String", "Share_URL", '"xxx/xx/"'
        }
        lintOptions {
            checkReleaseBuilds false
            // Or, if you prefer, you can continue to check for errors in release builds,
            // but continue the build even when errors are found:
            abortOnError false
        }
    }
}

dependencies { configuration ->
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'androidx.test:runner:1.2.0'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'

    androidX(configuration)
    playServices(configuration)
    fireBase(configuration)
    crashlytics(configuration)
    oneSignal(configuration)
    faceBook(configuration)
    retrofit(configuration)
    progressBar(configuration)
    toasty(configuration)
    multiSelectSpinner(configuration)
    picasso(configuration)
    circleImageView(configuration)
    imageSlider(configuration)
//    imageSliderAnimations(configuration)
    expandableRecyclerView(configuration)
    tagView(configuration)
    stepperIndicator(configuration)
    rateApp(configuration)
    lottieAnimations(configuration)
//    imagePicker(configuration)
    readMoreTextView(configuration)
    validation(configuration)
    implementation project(path: ':YouTubeAndroidPlayerApi')

}

private static void androidX(configuration) {
    def version = "1.0.0"

    configuration.implementation "com.google.android.material:material:$version"
    configuration.implementation "androidx.legacy:legacy-support-v4:$version"
    configuration.implementation "com.google.android.material:material:$version"
    configuration.implementation "androidx.recyclerview:recyclerview:$version"
    configuration.implementation "androidx.cardview:cardview:$version"
    configuration.implementation "androidx.legacy:legacy-support-v4:$version"
    configuration.implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
    configuration.implementation 'androidx.vectordrawable:vectordrawable:1.0.1'
    configuration.implementation 'androidx.appcompat:appcompat:1.1.0-rc01'

}

private static void playServices(configuration) {
    def version = "17.0.0"
    configuration.implementation "com.google.android.gms:play-services-location:$version"
    configuration.implementation "com.google.android.gms:play-services-places:$version"
    configuration.implementation "com.google.android.gms:play-services-maps:$version"
    configuration.implementation "com.google.android.gms:play-services-auth:$version"
    configuration.implementation 'com.google.android.gms:play-services-ads:18.1.1'
    configuration.implementation 'com.google.android.play:core:1.6.1'
}

private static void fireBase(configuration) {
    configuration.implementation 'com.google.firebase:firebase-perf:19.0.0'
    configuration.implementation 'com.google.firebase:firebase-core:17.1.0'
    configuration.implementation 'com.google.firebase:firebase-messaging:20.0.0'
    configuration.implementation 'com.google.firebase:firebase-invites:17.0.0'
    configuration.implementation 'com.google.firebase:firebase-appindexing:19.0.0'
}

 buildscript {

     repositories {
         google()
         jcenter()
         mavenCentral()
         maven { url 'https://maven.fabric.io/public' }
         maven { url 'https://plugins.gradle.org/m2/'}
     }
     dependencies {
         classpath 'com.android.tools.build:gradle:3.5.0'
         classpath 'com.google.gms:google-services:4.3.0'
         classpath 'io.fabric.tools:gradle:1.29.0'

         classpath 'com.google.firebase:perf-plugin:1.3.1'
         classpath 'gradle.plugin.com.onesignal:onesignal-gradle-plugin:0.12.1'

         // NOTE: Do not place your application dependencies here; they belong
         // in the individual module build.gradle files
     }
 }

 allprojects {
     repositories {
         google()
         jcenter()
         maven { url "https://jitpack.io" }
         maven { url 'https://maven.google.com/' }
     }
 }

 task clean(type: Delete) {
     delete rootProject.buildDir
 }

proguard 规则

-keepattributes *Annotation*

######## crashlytics
-keepattributes SourceFile,LineNumberTable
-keep public class * extends java.lang.Exception
########


######## saripaar
-keep class com.mobsandgeeks.saripaar.** {*;}
-keep @com.mobsandgeeks.saripaar.annotation.ValidateUsing class * {*;}
########

######## com.wang.avi:library
-keep class com.wang.avi.** { *; }
-keep class com.wang.avi.indicators.** { *; }
########

######## okhttp3
-dontwarn javax.annotation.**
-keepnames class okhttp3.internal.publicsuffix.PublicSuffixDatabase
-dontwarn org.codehaus.mojo.animal_sniffer.*
-dontwarn okhttp3.internal.platform.ConscryptPlatform
########

######## gson
-keep class sun.misc.Unsafe { *; }
-keep class com.google.gson.stream.** { *; }
########

######## stetho  debuging only
-keep class com.facebook.stetho.** { *; }
-dontwarn com.facebook.stetho.**
########

######## debuging
-dontobfuscate
-addconfigurationdebugging-keepattributes *Annotation*

######## crashlytics
-keepattributes SourceFile,LineNumberTable
-keep public class * extends java.lang.Exception
########


######## saripaar
-keep class com.mobsandgeeks.saripaar.** {*;}
-keep @com.mobsandgeeks.saripaar.annotation.ValidateUsing class * {*;}
########

######## com.wang.avi:library
-keep class com.wang.avi.** { *; }
-keep class com.wang.avi.indicators.** { *; }
########

######## okhttp3
-dontwarn javax.annotation.**
-keepnames class okhttp3.internal.publicsuffix.PublicSuffixDatabase
-dontwarn org.codehaus.mojo.animal_sniffer.*
-dontwarn okhttp3.internal.platform.ConscryptPlatform
########

######## gson
-keep class sun.misc.Unsafe { *; }
-keep class com.google.gson.stream.** { *; }
########

######## stetho  debuging only
-keep class com.facebook.stetho.** { *; }
-dontwarn com.facebook.stetho.**
########

######## debuging
-dontobfuscate
-addconfigurationdebugging

当我删除 firebase:perf 时,firebase-messaging

出现相同的错误

当我从 proguard 规则

中删除 -addconfigurationdebugging 时它起作用了