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

- **ID:** `android/install-failed-version-downgrade`
- **领域:** android
- **类别:** install_error
- **验证级别:** ai_generated
- **修复率:** 95%

## 根因

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

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| Android 12 | active | — | — |
| Android 13 | active | — | — |
| Android 14 | active | — | — |
| Android Studio Giraffe 2022.3.1 | active | — | — |
| Android Studio Hedgehog 2023.1.1 | active | — | — |

## 解决方案

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.
   ```

## 无效尝试

- **** — Uninstalling the app manually from device settings works but loses all user data; not ideal for debugging. (30% 失败率)
- **** — Using `adb install -r -d` flag may force downgrade on some custom ROMs but fails on stock Android with version downgrade check. (90% 失败率)
- **** — Modifying versionName only without changing versionCode has no effect because versionCode is the numeric identifier. (100% 失败率)
