Skip to content

Resolving "Version Code 1 Has Already Been Used" in Google Play Console

Problem Statement

When uploading a new Android app bundle to Google Play Console, developers frequently encounter the error: "Version code 1 has already been used. Try another version code." This occurs even after updating version information in configuration files like pubspec.yaml for Flutter projects.

The core issue is that Google Play requires each uploaded version of your app to have a unique and increasing version code to properly manage app updates and distribution.

Understanding Android Versioning

Android uses two distinct version identifiers:

  • Version Name: User-facing version (e.g., "1.0.0", "2.1.3")
  • Version Code: Internal numeric identifier that must increase with each release

In Flutter projects, these are typically defined in pubspec.yaml:

yaml
version: 1.0.0+1

Where:

  • 1.0.0 = Version Name (displayed to users)
  • +1 = Version Code (internal tracking number)

Solutions

Solution 1: Increment Version Code for New Releases

For apps already published to the Play Store, you must increment the version code with each new release.

yaml
# Change from:
version: 1.0.0+1

# To:
version: 1.0.0+2  # Or version: 2.0.0+2
gradle
defaultConfig {
    applicationId "com.your.app"
    minSdkVersion 21
    targetSdkVersion 34
    versionCode 2  // Increment this number
    versionName "1.0.1"
}

WARNING

Version codes must be positive integers and cannot be reused. Each new upload must have a higher version code than any previously published version.

Solution 2: Remove Draft Uploads

If you're testing and have uploaded bundles that weren't published (saved as drafts), you need to remove them:

  1. Go to Play Console → Release → App Bundle Explorer
  2. Select the app version from the dropdown
  3. Find the conflicting bundle and click Delete app build
  4. If delete option isn't available, go to Release overview → Discard release first
Step-by-step deletion process
  1. Navigate to App Bundle Explorer in Play Console
  2. Select the version with the conflicting build
  3. If "Delete app build" is available, use it
  4. If not, go to Release overview and discard the draft release
  5. Return to App Bundle Explorer - delete option should now be available

Solution 3: Manual Gradle Configuration (Advanced)

For complex scenarios where automatic versioning isn't working:

gradle
def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
// Override local properties if needed
flutterVersionCode = '2' // Your desired version code

Framework-Specific Guidance

Flutter

Primary method: Update pubspec.yaml:

yaml
version: 1.0.1+2

Alternative method: Build with specific versioning:

bash
flutter build appbundle --build-name=1.0.1 --build-number=2

React Native

Update android/app/build.gradle:

gradle
android {
    defaultConfig {
        versionCode 2
        versionName "1.0.1"
    }
}

Expo/React Native with Expo

Update app.json:

json
{
  "expo": {
    "version": "1.0.1",
    "android": {
      "versionCode": 2
    }
  }
}

Native Android

Update app/build.gradle as shown in Solution 1.

Best Practices

  1. Consistent Incrementing: Always increase version codes sequentially
  2. Version Naming: Use semantic versioning for version names (MAJOR.MINOR.PATCH)
  3. Documentation: Keep track of version codes used in previous releases
  4. Automation: Consider automating version code incrementing in CI/CD pipelines

Version Code Strategy

  • Use simple incrementing integers (1, 2, 3, ...)
  • For multi-flavor apps, use base numbers (1000, 2000) with offsets for different flavors
  • Never skip version codes in production releases

Common Mistakes to Avoid

  • Changing only the version name without updating the version code
  • Trying to reuse version codes from deleted draft releases
  • Modifying version code in the wrong configuration file
  • Using decimal points in version codes (they must be integers)

Troubleshooting

If you continue experiencing issues:

  1. Verify version codes in generated APK/AAB files
  2. Check that all configuration files are consistent
  3. Ensure you're modifying the correct build variant's configuration
  4. Clean and rebuild your project after changing version codes

By following these guidelines, you can resolve the "version code already used" error and maintain proper versioning for your Android applications on Google Play Console.