Firebase Database GetInstance Crash
Solution 1:
Please create the project on Firebase then add application with appropriate package name, put the downloaded json file in your app:
I think current file does not have
"project_info": {
"project_number": "566986018979",
"firebase_url": "https://test-fcm-17958.firebaseio.com",
"project_id": "test-fcm-17958",
"storage_bucket": "test-fcm-17958.appspot.com"
}
Firebase url it means didn't added any app yet on there may b some issue in project configuration
Also first try with default reference
mDatabase = FirebaseDatabase.getInstance().getReference();
Solution 2:
The problem was that every flavor of the app needed its own google-services.json file
So I added them to each falvor's module folder.
Hope this helps someone in the future!
Solution 3:
I will suggest to check the Firebase Authentication and download google-services.json from Project Settings in the Firebase Console .
I will suggest to try to use above solution. I hope it will work.
Solution 4:
Add implementation 'com.google.firebase:firebase-database:17.0.0' or latest version to build.gradle in Android Studio.
Console.firebase.google.com/project settings will also give you the com.google.firebase:firebase-core:x.x.x: version during configuration of new project. Just make both versions match in the gradle file.
This worked for me probably because a bug fix was implemented in later versions for the FirebaseDatabase.getInstance() method.
Solution 5:
When using Firebase Realtime Database in your app along with ProGuard, you need to consider how your model objects will be serialized and deserialized after obfuscation. If you use DataSnapshot.getValue(Class) or DatabaseReference.setValue(Object) to read and write data, you will need to add rules to the proguard-rules.pro file:
# Add this global rule
-keepattributes Signature
# This rule will properly ProGuard all the model classes in
# the package com.yourcompany.models.
# Modify this rule to fit the structure of your app.
-keepclassmembers class com.yourcompany.models.** {
*;
}
Ref: https://firebase.google.com/docs/database/android/start/
Post a Comment for "Firebase Database GetInstance Crash"