我最近使用Android Studio 3.3更新为Gradle Plugin 3.3.0
,但出现此错误:
io.reactivex.exceptions.OnErrorNotImplementedException: Default FirebaseApp is not initialized in this process <package-name>. Make sure to call FirebaseApp.initializeApp(Context) first.
at io.reactivex.internal.functions.Functions$OnErrorMissingConsumer.accept(Functions.java:704)
但是,它在AGP 3.2.0中运行正常
我的其他配置如下:
顶级build.gradle
文件:
buildscript {
...
ext.kotlin_version = '1.3.11'
ext.firebase_core = "16.0.6"
ext.firebase_messaging = "17.3.4"
ext.google_services_plugin_version = "4.1.0"
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.3.0'
...
classpath "com.google.gms:google-services:$google_services_plugin_version" // google-services plugin
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
...
}
...
应用build.gradle
文件:
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-kapt'
apply plugin: 'kotlin-android-extensions'
apply plugin: "androidx.navigation.safeargs"
android {
...
}
configurations {
...
}
dependencies {
...
//firebase
implementation "com.google.firebase:firebase-core:$firebase_core"
implementation "com.google.firebase:firebase-messaging:$firebase_messaging"
...
}
apply plugin: 'com.google.gms.google-services'
似乎AGP 3.3.0
与这些Firebase版本不兼容。我该怎么做才能解决这个问题?我更新了AGP 3.3.0
,因为我想使用R8解决proguard问题。