Engineering3 min read

Signed-in users treated as signed out on every cold start, only on some Android devices. We traced it to firebase-auth's encrypted session storage — here is the fix.

The short answer

If Firebase Auth signs Android users out on every cold start on some devices, check logcat for "Keystore cannot load the key" or "KeysetManager failed to initialize". firebase-auth 23.2.1 and later encrypt the saved session with an Android Keystore key that some devices cannot read. Forcing firebase-auth 23.1.0 and setting android:allowBackup="false" fixed it for us.

The symptom

In a Flutter app we run in production, a small number of users reported having to log in every time they opened the app. Not after an update, not after clearing data — every cold start. On most devices the session persisted exactly as it should. On a few, it simply vanished.

Nothing crashed and no error reached the app. firebase-auth quietly reported that no user was signed in, so the app correctly showed the login screen. From the user's side, the app had "forgotten" them.

Finding the cause

We eventually got hold of a device that reproduced the problem every single time, and the answer was in logcat, not in our code. On launch, firebase-auth's storage helper was logging Keystore failures:

FirebearStorageCryptoHelper: Keystore cannot load the key
KeysetManager failed to initialize

Why it happens

Starting with firebase-auth 23.2.1, the Android SDK encrypts the session it persists locally, using a key held in the Android Keystore. On some devices and firmware, that Keystore-backed key cannot be read back on a later launch. When decryption fails, firebase-auth cannot restore the saved session and behaves as if nobody is signed in.

It is device- and firmware-specific, which is why it looks random from a crash dashboard and never shows up on a developer's own phone. It is tracked in a long-running, still-open upstream issue (firebase/firebase-android-sdk#7651), and no fix had shipped upstream as of August 2026.

The fix: force firebase-auth 23.1.0

The version before the encrypted persistence path, 23.1.0, does not have the problem. If you use the Firebase BoM (as Flutter's firebase_auth plugin effectively does), the BoM will pick a newer firebase-auth, so you need to force the version for that one artifact. In android/app/build.gradle.kts:

configurations.all {
    resolutionStrategy {
        force("com.google.firebase:firebase-auth:23.1.0")
    }
}

Also disable Android Auto Backup

Keystore keys are tied to the device and are not included in Android's Auto Backup. If backup restores encrypted app data onto a device without the key that encrypted it, you can recreate the same unreadable-session problem on a new phone. We set allowBackup to false in AndroidManifest.xml:

<application
    ...
    android:allowBackup="false">

Worth knowing

Turning off Auto Backup means users start fresh on a new device — they sign in once. For an app that stores sessions and money, that is the right trade-off.

How we verified it

  • Reproduced the logout on a device that failed on every cold start
  • Confirmed the Keystore errors in logcat before the change
  • Applied the forced version and the backup change, rebuilt and reinstalled
  • Signed in, force-stopped and relaunched repeatedly — the session persisted every time

Before you copy this

  • Pinning an older SDK is a workaround, not a permanent state — watch the upstream issue and re-test when a fixed release ships
  • Re-check the pin whenever you bump the Firebase BoM or the FlutterFire plugins
  • Keep the reason in a comment next to the pin, so nobody "helpfully" removes it during an upgrade

Need a hand with a production app?

Bugs like this are why we care about building on foundations that hold. If your mobile app has a problem that only some users can see, book a 15-minute call — we like this kind of puzzle.

AL
“The hardest bugs are the ones with no error: the app did exactly what it was told, and the user still had a broken experience. A single device that reproduces the problem every time is worth more than a hundred crash reports.”
The Auralion Labs team

Questions people ask us.

On some devices, firebase-auth 23.2.1 and later cannot read the Android Keystore key used to encrypt the saved session, so it cannot restore the user and treats them as signed out. Look for "Keystore cannot load the key" or "KeysetManager failed to initialize" in logcat.

Force com.google.firebase:firebase-auth:23.1.0 with a resolutionStrategy in android/app/build.gradle.kts, and set android:allowBackup="false" in AndroidManifest.xml. Re-test on a device that reproduces the problem.

Yes. Flutter's firebase_auth plugin uses the native Android firebase-auth SDK, so the same Keystore problem applies, and the same Gradle version pin fixes it.

It is a workaround. Keep a comment explaining why the version is forced, watch the upstream issue, and re-test when a fixed firebase-auth release ships.

Keep reading.