FirebaseInitProvider: FirebaseApp initialization unsuccessful

匿名 (未验证) 提交于 2019-12-03 03:12:02

问题:

We have followed the Add Firebase to your Android Project but we can't see the app receiving data in the Firebase Console.
And when we launch the app, the log says:

FirebaseInitProvider: FirebaseApp initialization unsuccessful 

What does this mean? What are we doing wrong?
I can't find this error in the docs, nor here in StackOverflow.

回答1:

What does this mean? What are we doing wrong?

Would assume, that the authentication did not succeed.

a) the buildscript repositories and dependencies for the project level build.gradle:

buildscript {     repositories {         google()         jcenter()     }     dependencies {          // Android Build Tools Plugin         classpath "com.android.tools.build:gradle:3.0.1"          // Google Services Plugin         classpath "com.google.gms:google-services:3.1.2"          // Firebase Plugins (optional)         // classpath 'com.google.firebase:firebase-plugins:1.1.5'     } } 

b) the dependencies for the module level mobile/build.gradle (the Android Intel x86 images may still have a previous version of the Google Play Services installed, eg. 10.2.0 runs on the current x86 emulator, while 11.8.0 runs on my physical ARM device). referencing play-services and firebase-core will compile all their dependencies, unless excluding some them.

def playServicesVersion = "11.8.0"  android {     ...     buildTypes {         debug {             // suffixing the package name for debug builds,             // in order to partially mute the crash-reporting             // is an *optional* configuration (see below):             applicationIdSuffix ".debug"         }     } }  dependencies {     ...     // Google Play Services Library (in particular "play-services-auth")     compile("com.google.android.gms:play-services:${playServicesVersion}") {}      // Google Firebase Library     implementation "com.google.firebase:firebase-core:${playServicesVersion}"     // implementation "com.google.firebase:firebase-crash:${playServicesVersion}"     // implementation "com.google.firebase:firebase-perf:${playServicesVersion}" } 

c) the bottom line of mobile/build.gradle should be:

// apply the Google Services Plugin apply plugin: "com.google.gms.google-services" 

d) make sure to have the (downloaded) credentials available at app/google-services.json; on the Firebase Console, one has to add both SHA1 (or SHA256) hashes, of the debug and the release key-store, in order to have both builds authenticating properly; once all matches, it should report:

I/FirebaseInitProvider: FirebaseApp initialization successful 

It's all well documented, just see Setup Google Play Services, Firebase Quickstart or Crash Reporting; while I find this article on the Firebase Blog quite useful: Organizing your Firebase-enabled Android app builds, because it explains how to partially mute the crash-reporting. The release notes always announce the updates & changes.



回答2:

It happens when you dont have apply plugin: 'com.google.gms.google-services' in your app/build.gradle. Try adding it.

Also make sure you have Google Play services SDK installed in Android SDK Manager.



回答3:

The first thing I would advice you to check on is:

1) Have you included the uses-permission INTERNET in your Manifest ?



回答4:

I got the same logcat output.

Fixed it by updating my Google Play Services dependency to 9.0.0 in my app/build.gradle

and updating

buildScript {     //...     dependencies {         //...         classpath 'com.google.gms:google-services:3.0.0'     } } 

in my project build.gradle to 3.0.0



回答5:

In my case I was trying to Selectively compile Google play Services. Instead of using

compile 'com.google.android.gms:play-services:9.4.0' 

as described at: https://developers.google.com/android/guides/setup#ensure_devices_have_the_google_play_services_apk

I manually added maps and some other dependencies module from Google Play Services as

compile 'com.google.android.gms:play-services-maps:9.4.0' compile 'com.google.android.gms:play-services-places:9.4.0' 

Unfourtunately Firebase stoped working after this.

As a result I had to rollback and return to use

compile 'com.google.android.gms:play-services:9.4.0' 

instead of selectively.



回答6:

Make sure you have added this line to app level gradle build file

apply plugin: 'com.google.gms.google-services'



易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!