Firebase Realtime Database crashes when Android app is used offline


nishant pathak

I'm using firebase offline database in PreferenceScreen for my android application and loading dynamic configuration data.

  compile 'com.google.firebase:firebase-database:9.8.0'

Used as:

FirebaseDatabase.getInstance().getReference(fireBaseReference);

I use it following the tutorial : https://firebase.google.com/docs/database/

The app works fine when connected, while offline its crash is related to the stack trace below

Caused by: java.lang.IllegalStateException: Default FirebaseApp is not initialized in this process com.nishant.starterkit.mock. 
Make sure to call FirebaseApp.initializeApp(Context) first.
                                                                                 at com.google.firebase.FirebaseApp.getInstance(Unknown Source)
                                                                                 at com.google.firebase.database.FirebaseDatabase.getInstance(Unknown Source)
Chandra Sekhar

Your app appears to have multiple processes. Make sure to initialize the Firebase database only through the app's context.

    if (!FirebaseApp.getApps(this).isEmpty()) {
        FirebaseDatabase.getInstance().setPersistenceEnabled(true);
    }

You should initialize firebase DB as above.

Related


Firebase Realtime Database write crashes Android app

Adventune I am trying to write a simple code to write to Firebase Realtime Database. However, when opening an activity that writes to the database, the app crashes. Here is the code I am using: import androidx.appcompat.app.AppCompatActivity; import android.o

Firebase Realtime Database write crashes Android app

Adventune I am trying to write a simple code to write to Firebase Realtime Database. However, when opening an activity that writes to the database, the app crashes. Here is the code I am using: import androidx.appcompat.app.AppCompatActivity; import android.o

Firebase Realtime Database write crashes Android app

Adventune I am trying to write a simple code to write to Firebase Realtime Database. However, when opening an activity that writes to the database, the app crashes. Here is the code I am using: import androidx.appcompat.app.AppCompatActivity; import android.o

Firebase Realtime Database write crashes Android app

Adventune I am trying to write a simple code to write to Firebase Realtime Database. However, when opening an activity that writes to the database, the app crashes. Here is the code I am using: import androidx.appcompat.app.AppCompatActivity; import android.o

Firebase Realtime Database write crashes Android app

Adventune 我正在尝试编写一个简单的代码来写入Firebase实时数据库。但是,当打开写入数据库的活动时,该应用程序将崩溃。这是我正在使用的代码: import androidx.appcompat.app.AppCompatActivity; import android.os.Bundle; import android.view.View; import android.widget.Button; import com.google.firebase.database.DatabaseRefere

Firebase Realtime Database Transactions when offline

Wizlock I'm using the react-native-firebase package in a React Native app and trying to understand how transactions work offline. I am trying to write a transaction using the following code firebase.database().ref('locations').transaction(locations => { ..

Firebase Android App - not updating realtime database

song I'm getting some errors when trying to push data to Firebase Realtime Database. I checked some tutorials and according to all of them I am not doing anything wrong. Unfortunately I can't update the database from my android studio emulator device. I activa

Firebase Android App - not updating realtime database

song I'm getting some errors when trying to push data to Firebase Realtime Database. I checked some tutorials and according to all of them I am not doing anything wrong. Unfortunately I can't update the database from my android studio emulator device. I activa

Firebase Android App - not updating realtime database

song I'm getting some errors when trying to push data to Firebase Realtime Database. I checked some tutorials and according to all of them I am not doing anything wrong. Unfortunately I can't update the database from my android studio emulator device. I activa

Android Firebase Realtime Database Blog App

Finley Riba I am making a simple android firebase blog app I want to create a new post in my live database but only two properties are saved in the database Only the header and body properties are sent to my live database, the rest are lost and I don't see any

Firebase Android App - not updating realtime database

song I'm getting some errors when trying to push data to Firebase Realtime Database. I checked some tutorials and according to all of them I am not doing anything wrong. Unfortunately I can't update the database from my android studio emulator device. I activa

Firebase Android App - not updating realtime database

song I'm getting some errors when trying to push data to Firebase Realtime Database. I checked some tutorials and according to all of them I am not doing anything wrong. Unfortunately I can't update the database from my android studio emulator device. I activa

Firebase Android App - not updating realtime database

song I'm getting some errors when trying to push data to Firebase Realtime Database. I checked some tutorials and according to all of them I am not doing anything wrong. Unfortunately I can't update the database from my android studio emulator device. I activa

Android: Firebase Realtime Database

Shahbaz Ansari How to add complete information about the person of the date like name, age, gender etc so that the data can be retrieved with the given date For example one month or one day of data? Should I use an object to hold the data? and how to retrieve

How to handle offline transactions in Firebase Realtime Database?

username I have one that addValueEventListenerlistens for changes to any value in Firebase Realtime Database. In online mode everything works fine. But in offline mode, the device is offline and my web server has completed multiple transactions with the same v

Android App crashes when connecting to Firebase

Devansh Kumar I'm trying to connect to my firebase app, but when initializing firebase with my app url, the app crashes. The line below gives the error - Firebase myFirebaseRef = new Firebase("https://firebase-dummy.firebaseio.com/"); it gives IllegalAccessErr

Android app crashes when adding Firebase crashlytics

Rachuhotab I'm migrating from Fabric to Firebase crashlytics. I've been able to migrate to AndroidX (which I think is necessary). Then I followed the steps below, but when I add the crashlytics dependency, the app crashes (if I comment out the crashlytics impl

Android App crashes when connecting to Firebase

Devansh Kumar I'm trying to connect to my firebase app, but when initializing firebase with my app url, the app crashes. The line below gives the error - Firebase myFirebaseRef = new Firebase("https://firebase-dummy.firebaseio.com/"); it gives IllegalAccessErr

Android App crashes when connecting to Firebase

Devansh Kumar I'm trying to connect to my firebase app, but when initializing firebase with my app url, the app crashes. The line below gives the error - Firebase myFirebaseRef = new Firebase("https://firebase-dummy.firebaseio.com/"); it gives IllegalAccessErr

Android App crashes when connecting to Firebase

Devansh Kumar I'm trying to connect to my firebase app, but when initializing firebase with my app url, the app crashes. The line below gives the error - Firebase myFirebaseRef = new Firebase("https://firebase-dummy.firebaseio.com/"); it gives IllegalAccessErr

Android App crashes when connecting to Firebase

Devansh Kumar I'm trying to connect to my firebase app, but when initializing firebase with my app url, the app crashes. The line below gives the error - Firebase myFirebaseRef = new Firebase("https://firebase-dummy.firebaseio.com/"); it gives IllegalAccessErr

Android App crashes when connecting to Firebase

Devansh Kumar I'm trying to connect to my firebase app, but when initializing firebase with my app url, the app crashes. The line below gives the error - Firebase myFirebaseRef = new Firebase("https://firebase-dummy.firebaseio.com/"); it gives IllegalAccessErr

Android app crashes when adding Firebase crashlytics

Rachuhotab I'm migrating from Fabric to Firebase crashlytics. I've been able to migrate to AndroidX (which I think is necessary). Then I followed the steps below, but when I add the crashlytics dependency, the app crashes (if I comment out the crashlytics impl