FirebaseAuth not storing logged in user
I've implemented Firebase sign in via Google sign in. Flow looks fine most of the time. I monitor it with this piece of code:
val userFlow = firebaseAuth.authStateChanged
.onEach { debugLogDefault("user collected: ${it?.uid}") }
.stateIn(
repositoryScope,
SharingStarted.Eagerly,
null
)
On emulator or my Samsung S24 it acts normally. After sign in flow logs my logged in userId. After app relaunch same thing happens as expected.
But not on my Pixel 10 Pro... this one, behaves like it is not caching user data after signing in. Flow logs userid after I log in there and this doesn't change until app is alive. After relaunch tho it acts like the user never signed in and userFlow emits null
Devices OS:
- Pixel is running Android 16.
- Emulator is running Android 16
- S24 is running Android 15.
Same problem. Works on the emulator, but on my Pixel 9 Pro (Android 16) it clear the user when the app relaunches.
Same Problem
Not much help, but what's interesting is that it started randomly working again after 2 days, I'm pretty sure that I didn't change anything to do with firebase...
Sounds like it might be an issue with the firebase-android-sdk
Error: FirebearSt...yptoHelper -> Exception encountered during crypto setup: Keystore cannot load the key with ID: firebear_main_key_id_for_storage_crypto.W0RFRkFVTFRd+MTo0ODk2Mjc5MDkwXXXXX
KeysetManager failed to initialize - unable to decrypt data
I believe this happens while initializing the SDK.
I saw that a similar issue can be found in the official firebase-android-sdk -> https://github.com/firebase/firebase-android-sdk/issues/7111
Luckily this issue there has already been marked as resolved with the version 24.0.0 of the firebase auth (see the linked issue).
Unfortunately, the latest version of the gitlive/firebase-kotlin-sdk still uses firebase BOM 33.15.0 which contains 23.2.1 of the firebase auth library which the user in the linked issue mentions as used library!
So it looks like an upgrade of the firebase bom to the latest version could solve this issue automatically.