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

- **ID:** `android/install-failed-version-downgrade`
- **Domain:** android
- **Category:** install_error
- **Verification:** ai_generated
- **Fix Rate:** 95%

## Root Cause

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

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| Android 12 | active | — | — |
| Android 13 | active | — | — |
| Android 14 | active | — | — |
| Android Studio Giraffe 2022.3.1 | active | — | — |
| Android Studio Hedgehog 2023.1.1 | active | — | — |

## Workarounds

1. **Uninstall the existing app first: `adb uninstall com.example.app`, then install the new APK.** (100% success)
   ```
   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.** (95% success)
   ```
   Increment versionCode in build.gradle: `versionCode 3` (ensure it's higher than previous) and rebuild.
   ```

## Dead Ends

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