在Firebase项目中添加多个应用

在Firebase项目中添加多个应用

问题描述:

我在我的Firebase项目中添加了两个android应用,但是新添加的应用不断崩溃,并出现以下错误:

I have added two android apps in my firebase project, but the newly added app keeps crashing with following error:

Caused by: java.lang.IllegalStateException: Default FirebaseApp is not
initialized in this process com.x.y. Make sure to call
FirebaseApp.initializeApp(Context) first.

注意:我也尝试添加FirebaseApp.initializeApp(Context),但没有用.

Note : I tried adding FirebaseApp.initializeApp(Context) this too, but did not work.

在gradle文件中添加了依赖性:

Dependency added in gradle file:

{ ..... 


    def firebase_version = "16.0.1"

    implementation "com.google.firebase:firebase-core:$firebase_version"
    implementation "com.google.firebase:firebase-auth:$firebase_version"
    implementation "com.google.firebase:firebase-database:$firebase_version"
    implementation "com.google.firebase:firebase-analytics:$firebase_version"
    implementation "com.google.firebase:firebase-storage:$firebase_version"

}

对我来说,任何解决方案都无法在任何地方使用.仅此有效.只需将我的Google服务的等级从4.1.0下载到4.0.0在两个gradle文件中进行更改.

For me none of the solution worked that were given any where. Only this worked. Just had to download grade my google services from 4.1.0 to 4.0.0 Change it in both gradle files.

dependencies {
    classpath 'com.google.gms:google-services:4.0.0'
    /*classpath 'com.google.gms:google-services:4.1.0' <-- this was the problem */
}

因此,如果您更新了Google服务,请尝试降级或更改为较旧的版本.希望对您有帮助

So if you have updated the google services, just try to downgrade or change to an older version. Hope it helps