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

AndroidFlutterGoogle PlayGoogle Play-Console

Android Problem Overview


I am uploading new app bundle to play console and it is saying after uploading Version code 1 has already been used. Try another version code.

I have changed version number in pubspec.yaml from version number: 1.0.0+1 to 2.0.0+1 even though it is saying the same error

Android Solutions


Solution 1 - Android

You have two ways to solve this, if you released your bundle already, then you have to update your version code like in Len_X's answer,

If you're still developing and pushed app bundle for say, testing, and then you delete it, this bundle is saved as a draft with that version code. Therefore, it says that you can't use the same version because it already sees another one with the same version name.

Here's how you fix it:

  1. Go to the release section
  2. go to app bundle explorer, in the top right you should see a dropdown button for you app version, click on it.
  3. A bottomsheet will show containing all the previous app bundles you uploaded it. Delete the one with clashing bundle version and you're good to go.

Hope that solves your problem.

Solution 2 - Android

You can do it manually by going to "app_name/android/app/build.gradle" file. In defaultConfig section change version code to a higher number

  defaultConfig {
        applicationId "com.my.app"
        minSdkVersion 23
        targetSdkVersion 30
        versionCode 1 // Change to a higher number
        versionName "1.0.1" // Change to a higher number
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
        javaCompileOptions {
            annotationProcessorOptions {
                arguments = ["room.schemaLocation": "$projectDir/schemas".toString()]
            }
        }
    }

Solution 3 - Android

First go to the app/build.gradle

enter image description here

change versionCode and versionName like this (+1)

enter image description here

I think this will be helpful for someone ✌

Solution 4 - Android

For Flutter only: Goto Pubspec.yaml file and find version key and Change the value after the + sign.

For Example: In your pubspec.yaml file, if your version is like this version: 1.0.0+1 then change it to version: 1.0.0+2

Solution 5 - Android

You have to increment the +1, it should be +2 to indicate build number

Solution 6 - Android

if you remove apk then upload same version apk so you get Error Version code 1 has already been used. Try another version code in this situation you should remove version from App bundle explorer then upload same version apk.

Solution 7 - Android

If you're running into app bundle approval issues inside of the Google Play store with an Expo/React Native project, here are some tips:

  1. Google Play versioning is actually checking your AndroidManifest.xml file for versioning (/android/app/src/). This should get updated from Expo's app.json file (/app.json) during build, per their instructions.

app.json example section, where I've bumped my app up to a v2.0 - note the versionCode inside of the Android settings object AND the version at the settings object root both need to be adjusted:

{
  "name": "app-name",
  "displayName": "App Name",
  "expo": {
    "android": {
      "package": "app.here",
      "permissions": [],
      "versionCode": 2
    }
  },
  "version": "2.0.0"
}
  1. If your Android version isn't updating (possibly if you have a detached Expo app), you have to go directly into the AndroidManifest.xml file and make the modification there (/android/app/src/):

Example of AndroidManifest.xml (note your modifications happen on the <manifest> tag, using the android:versionCode and android:versionName:

<manifest 
  xmlns:android="http://schemas.android.com/apk/res/android" 
  package="com.aganashapp"
  android:versionCode="2"
  android:versionName="2.0"
>
  <uses-permission android:name="android.permission.INTERNET"/>
  <application
    android:name=".MainApplication"
    android:label="@string/app_name"
      android:icon="@mipmap/ic_launcher"
    android:allowBackup="false"
    android:theme="@style/AppTheme"
  >
    <meta-data android:name="expo.modules.updates.EXPO_UPDATE_URL" android:value="https://exp.host/@username/app-name" />
    <meta-data android:name="expo.modules.updates.EXPO_SDK_VERSION" android:value="42.0.0" />
    <meta-data android:name="expo.modules.updates.EXPO_RELEASE_CHANNEL" android:value="default" />

  <activity
    android:name=".MainActivity"
      android:label="@string/app_name"
      android:configChanges="keyboard|keyboardHidden|orientation|screenSize|uiMode"
      android:launchMode="singleTask"
      android:windowSoftInputMode="adjustResize"
      android:theme="@style/Theme.App.SplashScreen"
    >
      <intent-filter>
        <action android:name="android.intent.action.MAIN"/>
        <category android:name="android.intent.category.LAUNCHER"/>
      </intent-filter>
    </activity>
    <activity android:name="com.facebook.react.devsupport.DevSettingsActivity"/>
  </application>
</manifest>
  1. If you're still having issues, remember that Android versionCode and versionName are two different things. Android does not seem to recognize semver standards. versionCode increments as whole numbers (ie, if you went from semver v1.0.0 to v1.1.0 that is versionCode 1 to 2.

Solution 8 - Android

If you get the above error in the google play console, please change the version: in pubspec.yaml.

Reference. How to set build and version number of Flutter app

and me works enter image description here

Solution 9 - Android

with my flutter project building a release for android i faced the same issue. all was doing is change version code in Pubspec.yaml but did not seem to change my android version... so i went to Android folder and added version code manually in local.properties file : /project/android/local.properties

flutter.versionName=1.1.0

flutter.versionCode= from 1 to 4

Solution 10 - Android

  1. The first step change the version code
  2. The second step go to the other settings and change the bundle version code as well

Solution 11 - Android

I always used to increment version code in my android/app/build.gradle file, and it always used to work. Then, after a recent update in Android Studio, it suddenly didn't anymore, and I got this error!

I never cared to dig into the build.gradle code, but now, I did. Here, at the "TODO", is where I used to change the version code number:

def localProperties = new Properties()
def localPropertiesFile = rootProject.file('local.properties')
if (localPropertiesFile.exists()) {
    localPropertiesFile.withReader('UTF-8') { reader ->
        localProperties.load(reader)
    }
}

def flutterRoot = localProperties.getProperty('flutter.sdk')
if (flutterRoot == null) {
    throw new FileNotFoundException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")
}

def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
if (flutterVersionCode == null) {
    flutterVersionCode = '19' // TODO: ---Count up with each release
}

But that only works if the version code from the local.properties file comes back as "null"!... I just realized. So probably, all this time, my compiler never managed to get values from local properties, but now all of a sudden, it does!

So I found the android/local.properties file and tried changing the version code there:

sdk.dir=C:\\Users\\karol\\AppData\\Local\\Android\\sdk
flutter.sdk=C:\\src\\flutter
flutter.buildMode=release
flutter.versionName=1.0.0
flutter.versionCode=1   //Change this to 19 (my current version code number)

But that didn't work, because the moment I ran flutter build appbundle, this file changed itself back to the original values...

I then tried adding version code values to my AndroidManifest.xml file, according to serraosays' answer, but that didn't help me either.

Functioning work-around

In the end, I did this in the android/app/build.gradle file:

def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
//if (flutterVersionCode == null) {
    flutterVersionCode = '19' // TODO: ---Count up with each release
//}

That is, I commented out the condition. Now, my setting would over-write any value retrieved from the local.properties file.

If anyone can tell me the proper way to increment the version code number, I'm all ears!  But in the meantime, this worked for me, and hopefully for someone else as well.

Solution 12 - Android

There are two reasons for this error:

  1. First, is common given in other answers: you must increase the version number to send an update to Play Console. Eg. previous app version: 1.0.5+5 and next update must contain 1.1.2+6. The +6 must be next to the previous update present on your play console.
  2. Second reason for this error is you have skipped some numbers in between. Eg. Previous released version: 1.0.5+5 but the new version you are trying to release is 1.0.6+8. The +8 is not allowed directly, you must put +6 then +7 and then next numbers.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
Questionbalu kView Question on Stackoverflow
Solution 1 - AndroidMichael SolimanView Answer on Stackoverflow
Solution 2 - AndroidTitas ČerniauskasView Answer on Stackoverflow
Solution 3 - AndroidhexhadView Answer on Stackoverflow
Solution 4 - Androidbalu kView Answer on Stackoverflow
Solution 5 - AndroidLen_XView Answer on Stackoverflow
Solution 6 - AndroidadarshView Answer on Stackoverflow
Solution 7 - AndroidserraosaysView Answer on Stackoverflow
Solution 8 - AndroidRyosuke HujisawaView Answer on Stackoverflow
Solution 9 - AndroidNsamba IsaacView Answer on Stackoverflow
Solution 10 - AndroidLook DevView Answer on Stackoverflow
Solution 11 - AndroidKarolina HagegårdView Answer on Stackoverflow
Solution 12 - AndroidPriyansh jainView Answer on Stackoverflow