70

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

balu k
  • 1,869
  • 1
  • 8
  • 25
  • In my case, I have an updated version but the upload wasn't successful, So the version was uploaded but not added to the release. when I tried to re-upload it, I got that error. the solution in that case is selecting it from the library (no need to generate a new version)! – Shady Mohamed Sherif Mar 28 '22 at 19:04

12 Answers12

49

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.

Itai Dagan
  • 287
  • 2
  • 11
Michael Soliman
  • 1,190
  • 1
  • 5
  • 18
  • This is not a maintainable solution. – Len_X Jun 21 '21 at 09:08
  • 4
    @Len_X this solution is only for pre-releasing, if you release your app, then your solution is the right way – Michael Soliman Jun 22 '21 at 11:11
  • 2
    Thanks for the 2nd option (app bundle explorer). I had created a release and it was denying my upload. Didn't want to increment +1 to keep iOS version paired. – ce-loco Jul 07 '21 at 17:23
  • 3
    I can't see the "delete" option when I click on the dropdown, next to app version. Does it still work? – Jay N Nov 07 '21 at 20:14
  • This is what I was looking for as I had to update the bundle before publishing it. – gildniy Dec 20 '21 at 07:22
  • Even when you pre-release, you can increment the version code number! It's not the same as the version name, after all. I just published my blackbox version 1.0.0 with the version code 18. The user sees only "1.0.0". The "18" is only for Play Store. – Karolina Hagegård May 13 '22 at 07:40
  • @MichaelSoliman how to delete the app bundle in the bottomsheet? (step 3) , I can't find delete button/icon on the bottom sheet like this: https://i.stack.imgur.com/oFK0L.png – Alexa289 May 31 '22 at 09:55
47

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()]
            }
        }
    }
22

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 ✌

hexhad
  • 851
  • 10
  • 12
  • 3
    Super confusing to keep track of. – serraosays Sep 30 '21 at 15:23
  • However, this is just "default configurations"... Doesn't all the other code in the `android/app/build.gradle` file sometimes over-write the default values? Or this over-writes the other code?... In any case, feels like there is some proper way to do it, that we haven't yet figured out. – Karolina Hagegård May 13 '22 at 07:36
14

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

balu k
  • 1,869
  • 1
  • 8
  • 25
12

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

Len_X
  • 727
  • 10
  • 27
  • 3
    Shouldn't the build number be "scoped" from within the version number? `1.0.0+1` and `2.0.0+1` are obviously not the same version... – mgalgs Aug 13 '21 at 23:13
  • @OshMansor, by OP do you mean Len_X or balu k? Changing the version from `1.0.0+1` to `1.0.0+2` _or_ `2.0.0+1` should avoid the issue. Or are we saying that's not the case? If you increment the major version number, do you also need to increment the revision number? That is, `1.0.0+1` to `2.0.0+1` won't solve this issue, but `1.0.0+1` to `2.0.0+2` will? – Brandon Essler Oct 10 '21 at 16:01
  • 1
    @BrandonEssler OP=Len_X. And yes only your latter case would work i.e. `1.0.0+1` to `2.0.0+2`. I tried the former and it still would not let me pass the submission. – Osh Mansor Oct 12 '21 at 06:31
  • It's so confusing to delete the existing aab, I just couldn't and now the worst has happened, my apple version is 1.0.1 whereas my android is on 3.0.0(3).... – Aditya Peshave Dec 25 '21 at 01:18
5

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.

adarsh
  • 124
  • 1
  • 5
3

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.
serraosays
  • 6,621
  • 3
  • 31
  • 55
0

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

Ryosuke Hujisawa
  • 2,322
  • 1
  • 12
  • 15
0

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

Nsamba Isaac
  • 99
  • 10
0
  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
Martin Braun
  • 8,191
  • 8
  • 54
  • 91
Look Dev
  • 9
  • 1
  • If the person who asked knew how to change the "version code" they probably wouldn't have the error to begin with, though. Try and include some steps in your answer, so that people can actually follow them! – Karolina Hagegård May 12 '22 at 18:20
0

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.

0

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.
Priyansh jain
  • 700
  • 5
  • 13