Android app signing keys and why losing one is permanent
androidsigningkeystoreapkreleasebackup
Android only installs an update over an existing app if the new APK is signed with the same certificate. There is no recovery: lose the key and every user must uninstall (losing app data) and install fresh. For sideloaded apps with in-app updaters this is the single most important file in the project.
Conventions used across Justin's apps
- Release keystore in the repo root or
app/(for examplekeyboard-release.keystore,app/message-release.jks), gitignored, with passwords in a gitignoredlocal.propertiesorkey.propertiesread by Gradle. - A backup copy on the server under
/home/justin/backups/<app>-android-signing/(directory mode 700). Apps with backups there: keyboard, tokay, spectre, plus the F-Droid repo key inapps-fdroid-signing.
The debug-key trap
Several apps (Run, Spectre, Forge) shipped release APKs signed with the Android debug key (CN=Android Debug, ~/.android/debug.keystore). It works, but updates are now tied to that one file on one desktop. Deleting ~/.android/ makes the SDK silently generate a new key, and every installed copy is orphaned. If an app already shipped that way, back the debug keystore up and never rotate it; check a key with apksigner verify --print-certs or keytool -printcert -jarfile app.apk.
Debug vs release on the same phone
A debug build and a release build have different signatures. Going from one to the other requires uninstalling, which wipes everything stored only on the device (for an SMS app: stars, reactions, drafts, scheduled messages, block flags; messages re-sync from the system provider). It also drops the app's AndroidKeyStore keys, so any encrypted local database becomes unreadable.
flutter run makes this easy to trigger by accident: on INSTALL_FAILED_UPDATE_INCOMPATIBLE it offers to uninstall the old version and does so, wiping the release app's data. That is how TLDR lost a phone's only E2E message key in July 2026. Recovery path (Android Auto Backup) and rules in Debug installs wipe app data, and recovering it with Android Auto Backup.
Lessons from TLDR (Flutter)
- TLDR's original keystore was lost; a new one was generated in March 2026, so every APK older than that version cannot update in place and those users had to reinstall. The replacement keystore and its
key.propertiesare gitignored and backed up on the server under/home/justin/backups/tldr-android-signing/(passwords are in that project's private notes, not here). - In Flutter the Android versionCode comes from the
+buildsuffix ofpubspec.yamlversion:, not from any Dart version constant. TLDR's pubspec sat frozen at one value for months while the app version climbed; sideloaded updates did not care, but Play rejects an AAB whose versionCode was already used. The deploy script now refuses to run unless pubspec'sx.y.zmatches the app version and the build number is numeric and bumped. - APK is for direct sideload distribution; AAB is only for Google Play.
Device-owner apps
An app set as device owner (dpm set-device-owner) cannot change its signing key later. Install the release-signed build on day one. See Locking down an Android phone with a device-owner app.
Other identity mistakes to avoid
- A package id still named
com.example.*is permanent once users install it. - A versionCode that never changes (always 1) means stores and F-Droid never see an update. See A self-hosted F-Droid repository and APK catalog.
See also
- In-app updates for sideloaded Android apps
- Debug installs wipe app data, and recovering it with Android Auto Backup
Linked from
- A self-hosted F-Droid repository and APK catalog
- Android TV / Google TV apps (Compose for TV, Media3, sideloading)
- Building an Android browser on GeckoView (Tokay)
- Debug installs wipe app data, and recovering it with Android Auto Backup
- Flutter Android release builds, app size, and store rollout
- In-app updates for sideloaded Android apps
- Keeping a web app and an Android app identical without a framework
- Keyboard, Justin's Android input method (overview and canon)
- Locking down an Android phone with a device-owner app
- Making a Flutter app an Android share target (native, no plugin)
- Offline voice dictation with fuzzy matching against a catalog
- Sharing a generated image from an Android WebView app (FileProvider, ClipData)