FirebaseApp Client in Scala
How to properly load the FirebaseAuth Java client in Scala
While I was using the FirebaseAuth
Java client, I was getting this error:
Execution exception[[IllegalStateException: FirebaseApp name [DEFAULT] already exists!]]
When my Play application reloaded itself, FirebaseApp.initializeApp()
was getting called again from the application loader, which caused this error.
I made a simple wrapper to handle this:
We simply just try to get the Firebase app instance (wrapped in a Try
), and if it doesn't exist, we initialize it, which should happen just once.
Using this wrapper is as simple as val firebaseApp: FirebaseApp = FirebaseAppLoader(credentials)
. Or with macwire, val firebaseApp: FirebaseApp = wireWith(FirebaseAppLoader(_))
.
Last updated