android install_error ai_generated true

INSTALL_FAILED_VERSION_DOWNGRADE: Existing version code 2 is greater than new version code 1

ID: android/install-failed-version-downgrade

Also available as: JSON · Markdown · 中文
95%Fix Rate
90%Confidence
1Evidence
2023-01-10First Seen

Version Compatibility

VersionStatusIntroducedDeprecatedNotes
Android 12 active — — —
Android 13 active — — —
Android 14 active — — —
Android Studio Giraffe 2022.3.1 active — — —
Android Studio Hedgehog 2023.1.1 active — — —

Root Cause

Attempting to install an APK with a lower versionCode than the currently installed app, which Android prevents for security reasons.

generic

中文

尝试安装版本代码低于当前已安装应用的 APK,Android 出于安全原因阻止此操作。

Official Documentation

https://developer.android.com/studio/command-line/adb#install

Workarounds

  1. 100% success Uninstall the existing app first: `adb uninstall com.example.app`, then install the new APK.
    Uninstall the existing app first: `adb uninstall com.example.app`, then install the new APK.
  2. 95% success Increment versionCode in build.gradle: `versionCode 3` (ensure it's higher than previous) and rebuild.
    Increment versionCode in build.gradle: `versionCode 3` (ensure it's higher than previous) and rebuild.

中文步骤

  1. Uninstall the existing app first: `adb uninstall com.example.app`, then install the new APK.
  2. Increment versionCode in build.gradle: `versionCode 3` (ensure it's higher than previous) and rebuild.

Dead Ends

Common approaches that don't work:

  1. 30% fail

    Uninstalling the app manually from device settings works but loses all user data; not ideal for debugging.

  2. 90% fail

    Using `adb install -r -d` flag may force downgrade on some custom ROMs but fails on stock Android with version downgrade check.

  3. 100% fail

    Modifying versionName only without changing versionCode has no effect because versionCode is the numeric identifier.