android install_error ai_generated true

INSTALL_FAILED_VERSION_DOWNGRADE:现有版本代码 2 大于新版本代码 1

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

ID: android/install-failed-version-downgrade

其他格式: JSON · Markdown 中文 · English
95%修复率
90%置信度
1证据数
2023-01-10首次发现

版本兼容性

版本状态引入弃用备注
Android 12 active
Android 13 active
Android 14 active
Android Studio Giraffe 2022.3.1 active
Android Studio Hedgehog 2023.1.1 active

根因分析

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

English

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

generic

官方文档

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

解决方案

  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.

无效尝试

常见但无效的做法:

  1. 30% 失败

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

  2. 90% 失败

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

  3. 100% 失败

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