APK errors

INSTALL_FAILED_VERSION_DOWNGRADE

Error text

Failure [INSTALL_FAILED_VERSION_DOWNGRADE]
Package com.example.app new version 5 is older than the installed version 8

Cause

The versionCode of the APK you install is lower than the one on the phone. Android refuses to go backwards.

Step-by-step fix

  1. See the phone's number with adb shell dumpsys package pkg | grep versionCode.
  2. Raise versionCode in build.gradle above it.
  3. For testing, allow downgrade with adb install -r -d app.apk (for debuggable APKs).
  4. If that fails, uninstall the app and install fresh.
  5. Every Play upload needs a higher versionCode.

Example commands

adb shell dumpsys package com.example.app | grep versionCode
adb install -r -d app.apk
# build.gradle: versionCode = 9

How to prevent it

Increase versionCode automatically in CI (for example from the build number).

Author and license: Nibras Code