firebase / firebase/firebase-android-sdk

Documentation: Can't recreate default Firebase App

Open
#890 7 comments 1 reaction 0 assignees View on GitHub
api: core type: feature request
Dominant language
Java
Stars
2.6k
Forks
710
Avg merge
2d 9h
Merged PRs (30d)
31

Description

### Describe your environment

* Android Studio version: 3.4.2
* Firebase Component: Database
* Component version: 19.1.0

### Describe the problem

```
Caused by java.lang.IllegalStateException
FirebaseApp was deleted
com.google.android.gms.common.internal.Preconditions.checkState (Preconditions.java:9)
com.google.firebase.FirebaseApp.checkNotDeleted (FirebaseApp.java:509)
com.google.firebase.FirebaseApp.getName (FirebaseApp.java:182)
com.google.firebase.auth.internal.zzv. (zzv.java:54)
com.google.firebase.auth.internal.zzas. (zzas.java:6)
com.google.firebase.auth.FirebaseAuth.zzct (FirebaseAuth.java:9)
com.google.firebase.auth.FirebaseAuth.addIdTokenListener (FirebaseAuth.java:8)
com.google.firebase.database.android.AndroidAuthTokenProvider$1.addTokenChangeListener (AndroidAuthTokenProvider.java:57)
com.google.firebase.database.core.Repo.deferredInitialization (Repo.java:110)
com.google.firebase.database.core.Repo.access$000 (Repo.java:56)
com.google.firebase.database.core.Repo$1.run (Repo.java:95)
java.util.concurrent.Executors$RunnableAdapter.call (Executors.java:458)
java.util.concurrent.FutureTask.run (FutureTask.java:266)
java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run (ScheduledThreadPoolExecutor.java:301)
java.util.concurrent.ThreadPoolExecutor.runWorker (ThreadPoolExecutor.java:1167)
java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor.java:641)
java.lang.Thread.run (Thread.java:764)
```

And

```
Fatal Exception: java.lang.RuntimeException
Uncaught exception in Firebase Database runloop (3.0.0). Please report to firebase-database-client@google.com
com.google.firebase.database.android.AndroidPlatform$1$1.run (AndroidPlatform.java:96)
android.os.Handler.handleCallback (Handler.java:873)
android.os.Handler.dispatchMessage (Handler.java:99)
android.os.Looper.loop (Looper.java:205)
android.app.ActivityThread.main (ActivityThread.java:6983)
java.lang.reflect.Method.invoke (Method.java)
com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:493)
com.android.internal.os.ZygoteInit.main (ZygoteInit.java:884)
```

#### Steps to reproduce:

We haven't been able to pinpoint how this is occuring, however our setup is we dynamically can switch between firebase environments. We've spent a few days trying to replicate, unfortunately only our customers are finding this issue.

#### Relevant Code:

```
private fun updateFirebase(environment: Environment) {
firebaseApp?.delete()

when (environment) {
Environment.Unknown,
Environment.NotSet -> { /* We don't need to do anything here */
return
}
Environment.Dev -> {
FirebaseApp.initializeApp(context, AppConfiguration.instance.firebaseDev)
}
Environment.Staging -> {
FirebaseApp.initializeApp(context, AppConfiguration.instance.firebaseStage)
}
Environment.Prod -> {
FirebaseApp.initializeApp(context, AppConfiguration.instance.firebaseProd)
}
Environment.Europe -> {
FirebaseApp.initializeApp(context, AppConfiguration.instance.firebaseEurope)
}
}

FirebaseDatabase.getInstance().setPersistenceEnabled(false)
}
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.