如何使新的 Firebase Crashlytics 与 Android Studio 4 "Apply Changes" 一起工作?

How to make the new Firebase Crashlytics work with Android Studio 4 "Apply Changes"?

自从我从 Fabric Crashlytics 更新到 Firebase Crashlytics 后,“应用更改并重新启动 Activity”选项失败并显示以下消息:

Changes were not applied.
Modifications to AndroidManifest.xml require an app restart.
Manifest 'AndroidManifest.xml' was modified.

此外,每当我尝试使用“运行 应用程序”重新运行应用程序时,启动时都会抛出以下异常:

E/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.example.firebasetest, PID: 11320
    java.lang.RuntimeException: Unable to get provider com.google.firebase.provider.FirebaseInitProvider: java.lang.IllegalStateException: The Crashlytics build ID is missing. This occurs when Crashlytics tooling is absent from your app's build configuration. Please review Crashlytics onboarding instructions and ensure you have a valid Crashlytics account.
        at android.app.ActivityThread.installProvider(ActivityThread.java:6988)
        at android.app.ActivityThread.installContentProviders(ActivityThread.java:6528)
        at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6445)
        at android.app.ActivityThread.access00(ActivityThread.java:219)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1859)
        at android.os.Handler.dispatchMessage(Handler.java:107)
        at android.os.Looper.loop(Looper.java:214)
        at android.app.ActivityThread.main(ActivityThread.java:7356)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930)
     Caused by: java.lang.IllegalStateException: The Crashlytics build ID is missing. This occurs when Crashlytics tooling is absent from your app's build configuration. Please review Crashlytics onboarding instructions and ensure you have a valid Crashlytics account.
        at com.google.firebase.crashlytics.internal.common.CrashlyticsCore.onPreExecute(CrashlyticsCore.java:122)
        at com.google.firebase.crashlytics.FirebaseCrashlytics.init(FirebaseCrashlytics.java:165)
        at com.google.firebase.crashlytics.CrashlyticsRegistrar.buildCrashlytics(CrashlyticsRegistrar.java:55)
        at com.google.firebase.crashlytics.CrashlyticsRegistrar.access$lambda[=13=](Unknown Source:0)
        at com.google.firebase.crashlytics.CrashlyticsRegistrar$$Lambda.create(Unknown Source:2)
        at com.google.firebase.components.ComponentRuntime.lambda$new[=13=](com.google.firebase:firebase-components@@16.0.0:69)
        at com.google.firebase.components.ComponentRuntime$$Lambda.get(Unknown Source:4)
        at com.google.firebase.components.Lazy.get(com.google.firebase:firebase-components@@16.0.0:53)
        at com.google.firebase.components.ComponentRuntime.initializeEagerComponents(com.google.firebase:firebase-components@@16.0.0:158)
        at com.google.firebase.FirebaseApp.initializeAllApis(com.google.firebase:firebase-common@@19.3.0:563)
        at com.google.firebase.FirebaseApp.initializeApp(com.google.firebase:firebase-common@@19.3.0:304)
        at com.google.firebase.FirebaseApp.initializeApp(com.google.firebase:firebase-common@@19.3.0:268)
        at com.google.firebase.FirebaseApp.initializeApp(com.google.firebase:firebase-common@@19.3.0:253)
        at com.google.firebase.provider.FirebaseInitProvider.onCreate(com.google.firebase:firebase-common@@19.3.0:51)
        at android.content.ContentProvider.attachInfo(ContentProvider.java:2092)
        at android.content.ContentProvider.attachInfo(ContentProvider.java:2066)
        at com.google.firebase.provider.FirebaseInitProvider.attachInfo(com.google.firebase:firebase-common@@19.3.0:45)
        at android.app.ActivityThread.installProvider(ActivityThread.java:6983)
        at android.app.ActivityThread.installContentProviders(ActivityThread.java:6528) 
        at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6445) 
        at android.app.ActivityThread.access00(ActivityThread.java:219) 
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1859) 
        at android.os.Handler.dispatchMessage(Handler.java:107) 
        at android.os.Looper.loop(Looper.java:214) 
        at android.app.ActivityThread.main(ActivityThread.java:7356) 
        at java.lang.reflect.Method.invoke(Native Method) 
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492) 
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930)

运行应用程序再次运行正常。

要升级,我已按照 this link 中的说明进行操作,但我没有添加 Google Analytics SDK。我已经尝试包含它,但问题仍然存在。

我还删除了 Crashlytics 特定的构建文件 ext.alwaysUpdateBuildIdext.enableCrashlytics

以下是 gradle 文件的相关摘录:

项目级build.gradle:

buildscript {
    repositories {
        google()
        jcenter()
        mavenCentral()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.4.2'
        classpath 'com.google.gms:google-services:4.2.0'
        classpath 'com.google.firebase:firebase-crashlytics-gradle:2.2.0'
    }
}

感谢任何帮助。

刚刚升级

classpath 'com.android.tools.build:gradle:3.4.2'

classpath 'com.android.tools.build:gradle:4.0.1'