Debug installs wipe app data, and recovering it with Android Auto Backup
androidflutter-runsigningauto-backupdata-lossincidentadb
flutter run (or adb install of a debug build) onto a phone that has the release app installed
hits INSTALL_FAILED_UPDATE_INCOMPATIBLE, because the debug signature differs. Flutter's helpful
response is "Uninstalling old version..." followed by a reinstall, which deletes all app data,
SharedPreferences included. For an E2E-encrypted app whose only copy of a private key lives in
those prefs, that is unrecoverable message loss. It happened on 2026-07-01 to Justin's daily phone;
the data came back only because Android Auto Backup had a copy.
Rules
- Never
flutter runor adb-install onto any physical device until its owner confirms it holds no data they care about. Ask every time. "The phone that is plugged in" is not "the test phone". - In-place updates with the same release signature are safe; a debug build over a release app is not. Test with a release APK update, an emulator, or a genuinely disposable device.
- For changes touching keys, credentials or local persistence, deploy the data-safety part to production before device testing, so a backup path exists before anything can go wrong.
- Treat every device as production data until proven otherwise.
Recovery with Android Auto Backup
If the manifest does not set android:allowBackup, it defaults to true, and Android
periodically backs up the app's data (including SharedPreferences) to the user's Google account,
per signing identity. The debug build's data was stored separately and did not overwrite the
release app's backup. Steps that worked:
1. Put the phone in airplane mode immediately, so a fresh backup of the now-empty app does not
overwrite the good cloud copy.
2. Check Settings > Google > Backup for a recent backup.
3. Uninstall the debug app and install the release APK (same signing key as the backup). On
first launch Android restores the backup automatically.
4. Update in place to the fixed build and make sure the data now also lives somewhere durable
(here: log out and in once so the key was archived server-side, then verify on the server).
Keep allowBackup on for apps whose local state matters, unless you have a better backup story.
Diagnosing whether a key was really lost
- On a debug build you can read app prefs directly:
adb shell run-as <package> cat /data/data/<package>/shared_prefs/FlutterSharedPreferences.xml(run-asdoes not work on release builds). - Then test the candidate key against real server ciphertext; see the forensic recipe in Simple E2E messaging with X25519 + HKDF + AES-GCM (and why not Signal). In this incident the post-wipe key decrypted 0 of N messages and the contacts had not rotated, which proved the original key was gone from the device.
See also
- Android app signing keys and why losing one is permanent
- E2E key management that never loses a key (keyring, backup, re-wrap)