FirebaseApp not initializing despite FirebaseApp.initializeApp() being called in Application class

后端 未结 8 890
佛祖请我去吃肉
佛祖请我去吃肉 2021-01-11 09:59

I am creating an Android application and I\'m currently trying to implement user authentication using Firebase. As far as I can tell, my app is connected to my Firebase serv

相关标签:
8条回答
  • 2021-01-11 10:27

    Just as qbix stated, you much use the API calls from whichever version you are going to use. If possible, you should use the newer API because it will definitely be supported much further into the future.

    See the docs here:

    https://firebase.google.com/docs/database/android/start/

    Remove:

    Firebase.setAndroidContext(this);
    FirebaseApp.initializeApp(this);
    

    And put:

    FirebaseDatabase database = FirebaseDatabase.getInstance();
    

    If qbix puts his comment into an answer, you should accept his rather than mine seeing has how he beat me by a few minutes.

    Also:

    If you are using the old firebase and need help switching, this guide is spot on and will help you with the switch. It's a fairly simple switch.

    https://firebase.google.com/support/guides/firebase-android

    0 讨论(0)
  • 2021-01-11 10:29

    First check up should be the Firebase documentation and the tools from

    Android Studio -> Tools -> Firebase -> Cloud Messaging.

    Even if you have done that before.

    See this, that and that.

    Again, even if you already done that before as firebase versions tend to require an up to date configuration JSON.

    0 讨论(0)
  • 2021-01-11 10:30

    After much frustration, enabling Internet Permissions fixed this issue for me.

    0 讨论(0)
  • 2021-01-11 10:36

    Upgrading classpath 'com.google.gms:google-services:4.1.0' to classpath 'com.google.gms:google-services:4.2.0' in the project Gradle worked for me.

    0 讨论(0)
  • 2021-01-11 10:38

    I know there's already an accepted answer. However, I ran into the same error message saying: java.lang.IllegalStateException: Default FirebaseApp is not initialized in this process (name). Make sure to call FirebaseApp.initializeApp(Context). I tried several solutions found on SO, and double checking everything, until I finally found that the package name defined in the Firebase Console didn't match the package name defined in my manifest file.

    Try go to your Firebase Console -> Project settings -> check if package names matches.

    Hope it may help some :)

    0 讨论(0)
  • 2021-01-11 10:42

    It is easier to use the Firebase wizard that is included in Android Studio: it adds all the dependencies in the gradle files, creates the firebase project if needed, connects the app with the project, etc.

    In Android Studio open menu Tools / Firebase and follow the instructions.

    Then FirebaseApp.initializeApp() will return a valid value.

    0 讨论(0)
提交回复
热议问题