. Advertisement .
..3..
. Advertisement .
..4..
The error: “firebase real-time database unable to write data” is a common error that can show up in many ways. In this blog, we will go through some of the ways you can fix this issue. Read on.
When does the error: “firebase real-time database unable to write data” happen?
You are using Firebase in your project and attempting to write data to the database; however, the real-time database in Firebase isn’t allowing you to do so. You are having trouble with the following error.
2021-08-06 22:57:51.467 8980-8980/? E/e.firebasefetc: Unknown bits set in runtime_flags: 0x8000
2021-08-06 22:57:52.207 8980-9018/com.example.upcApp E/Perf: Fail to get file list com.example.upcApp
2021-08-06 22:57:52.208 8980-9018/com.example.upcApp E/Perf: getFolderSize() : Exception_1 = java.lang.NullPointerException: Attempt to get length of null array
2021-08-06 22:57:52.209 8980-9018/com.example.upcApp E/Perf: Fail to get file list com.example.upcApp
2021-08-06 22:57:52.209 8980-9018/com.example.upcApp E/Perf: getFolderSize() : Exception_1 = java.lang.NullPointerException: Attempt to get length of null array
2021-08-06 22:57:52.553 8980-8980/com.example.upcApp E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.upcApp, PID: 8980
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.upcApp/com.example.upcApp.MainActivity}: java.lang.IllegalStateException: Default FirebaseApp is not initialized in this process com.example.upcApp. Make sure to call FirebaseApp.initializeApp(Context) first.
You have got trouble with “firebase real-time database unable to write data” problem because something in google-services: 4.3.9 has been damaged. Another reason is that SDK cannot specify your database on the server.
How to resolve ” firebase real-time database unable to write data” error
Approach 1: Downgrade google-services to version 4.3.8
Something in google-services: 4.3.9 has been damaged. Therefore, you have to do now is downgrade google-services to google-services: 4.3.8. Here’s how to do it. Simply change the line below in your build.gradle file:
From
classpath 'com.google.gms:google-services:4.3.9'
To
classpath 'com.google.gms:google-services:4.3.8'
Approach 2: Use two options
It’s possible that the SDK will not be able to locate your database on the server if you build the Firebase console after downloading the google-services.json file. The reason is that file does not include the exact URL.
You have two options for resolving the issue “firebase real-time database unable to write data”:
- Use an upgaded google-services.json in your app after downloading it.
- Use FirebaseDatabase database = FirebaseDatabase.getInstance(“database URL at this place”); to provide the database URL in your code.
After doing that, your error will be completely resolved.
Conclusion
We hope you enjoyed our article about the error. With this knowledge, we know that you can fix your issue: “firebase real-time database unable to write data” quickly by following these steps! If you still have any other questions about fixing this syntax error, please leave a comment below. Thank you for reading!
Read more
Leave a comment