APK errors

Play: versionCode already used

Error text

Version code 12 has already been used. Try another version code.

Cause

An AAB with the same versionCode was uploaded before (even a rejected or draft one). Every upload needs a new number.

Step-by-step fix

  1. See the highest versionCode in App bundle explorer in Play Console.
  2. Write a larger number in build.gradle.
  3. versionName is only a label and does not replace versionCode.
  4. Increase the number automatically in CI.
  5. Run bundleRelease again and upload.

Example commands

android { defaultConfig { versionCode = 13; versionName = "1.4.0" } }
# CI-da avtomatik
versionCode = (System.getenv("BUILD_NUMBER") ?: "1").toInt()
./gradlew bundleRelease

How to prevent it

Generate versionCode from the build number or date, not by hand.

Author and license: Nibras Code