140

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
  • 3,515
  • 2
  • 14
  • 29
  • 2
    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

20 Answers20

135

You have two ways to solve this, if you released your bundle already, then you have to update your version code like in balu k'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.

Michael Soliman
  • 2,240
  • 3
  • 7
  • 20
  • 5
    This is not a maintainable solution. – Len_X Jun 21 '21 at 09:08
  • 7
    @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
  • 4
    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
  • FYI I was testing around and uploaded four app bundles for closed testing. Not sure why only the release 4 and 2 can be deleted. The "Delete app bundle" button does not show up for release 1 and 3. – midnite Jun 17 '22 at 20:36
  • 3
    The bundle I was trying to delete was used in a draft release and I couldn't find the delete bundle button. After I deleted the release, the delete bundle button appeared. :) – Mahmoud Mousa Hamad Jun 20 '22 at 10:45
  • Perhaps its changed over the years, but what does the dropdown look like? – Seth Schaffner Apr 06 '23 at 02:08
  • GOTO -> App Bundle Explorer. Scroll down. There you will find the builds. Select it. You will find "Delete" button in the bundle details page. – Bakhtawar Jul 30 '23 at 09:17
82

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()]
            }
        }
    }
Titas Černiauskas
  • 1,025
  • 1
  • 5
  • 17
  • For what it's worth, I have the versionCode set to `40000` and version Name set to `"4.0"` in my build.gradle, and the app bundle still gets 1/"1.0" – Edward Falk Jun 06 '22 at 01:09
  • 3
    For those who are using Expo and EAS with a managed app and don't have access to the Android folder: add the "versionCode" key in your app.json file, inside the "android" key. – Thales Ludwig Oct 09 '22 at 00:16
  • more details can be found in the expo docs about "versionCode" https://docs.expo.dev/build-reference/app-versions/ – Naresh Sep 02 '23 at 23:18
47

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
  • 3,515
  • 2
  • 14
  • 29
  • No, it isn't!... You don't even have to put a number after the plus sign of you don't want to! You can just put "1.0.1" for example. – Karolina Hagegård May 17 '22 at 22:46
  • 5
    @Karolina Hagegård, not true. I got the error when I put "1.0.1" and my previous release was "1.0.0" without the plus sign. Putting "1.0.1+2" for the new release was accepted and the error disappears. – Roslan Amir Aug 09 '22 at 09:48
  • Not for me... But I believe now this has something to do with the `build.gradle` files over-writing some of the values from the `pubspec.yaml` file, depending on settings... I removed an "if" statement for over-writing null value in one of my `build.gradle` files and it solved my problem. – Karolina Hagegård Aug 13 '22 at 14:45
  • 1
    Indeed!! I'm uploading my first app and after solving some complaint and re uploading the corrected bundle I got the error..tried increasing to `1.0.1+1` but it worked only when increased the `+1` to `1.0.0.0+2`, no other change would work. Many thanks – Vincenzo Feb 15 '23 at 14:14
  • 2
    In 1.0.0+1, the value before + translates to Version Code and the value after + translates to Version Name. You could use 1.0.1+alpha or 1.0.1+beta etc. On Google Play, each successive Version Code should be higher than previous one and each Version Name needs to be different (can be alpha-numeric). – Prashant Agarwal Feb 24 '23 at 18:12
38

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
  • 1,139
  • 12
  • 14
  • 4
    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
  • This worked for me. It should be set as "Correct answer". – Alex8752 Apr 10 '23 at 18:03
19

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

Len_X
  • 825
  • 11
  • 29
  • 5
    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
  • 1
    @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
  • 2
    @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
12

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
  • 403
  • 3
  • 8
6

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
  • 7,163
  • 3
  • 35
  • 60
1

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
  • 357
  • 4
  • 14
1

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.

Karolina Hagegård
  • 1,180
  • 5
  • 26
  • 1
    Bro I got the same problem as you, Local properties value always reset or return as null. I found out, caused by wrong path, the end with Sdk not sdk. so check your : sdk.dir=C:\\Users\\karol\\AppData\\Local\\Android\\sdk Compare to your local path, whether it is exactly the same. Case sensitive. Please lemme know if it solved. – SY MY Mar 29 '23 at 09:22
  • Interesting... I'm not coding at the moment, but I'll look into it when I have a chance, and let you know! :) – Karolina Hagegård Apr 10 '23 at 04:21
1

Versioning works the other way around. Do not update the pubspec.yaml manually.

See the default comment in the pubspec.yaml:

# Both the version and the builder number may be overridden in flutter
# build by specifying --build-name and --build-number, respectively.

So you should run

flutter build appbundle --build-name 2.0.0 --build-number 2

This updates the pubspec.yaml for you.

Mart-Jan
  • 47
  • 10
1

For the pre-release version, I solved this problem: Create a new release in Production. Choose "Add from library" where we upload apk. Then choose the same apk for testing.

Murat K.
  • 21
  • 1
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,682
  • 1
  • 17
  • 18
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
  • 1,065
  • 10
  • 17
0

In unreal engine you can change this in project settings. Steps are as follows. (Me I'm using UE4.27.2)

  1. Open Project Settings
  2. Click all settings and in the top search bar type in "version" Without Quotes.
  3. Scroll down to >Platforms>Android>apk packaging
  4. Change the store Version for each +1 what you already have APK PAckaging

(You do not need to change version display name but you can if you want to this can be edited later on in google console)

General Grievance
  • 4,555
  • 31
  • 31
  • 45
0

change version code here please check the imageenter image description here

0

For hybrid apps/JavaScript based frameworks like Ionic or Flutter updating package.json is not enough you sometimes, can directly edit build.gradle file in the build folder.

versionCode 2
versionName "2.0"

This is not a good practice

BorisD
  • 1,611
  • 17
  • 22
0

So, the version codes are internal codes not displayed to the app users publicly. When we rebuild the app with a new version, we usually increment the version code by 1 every time.

Now, let's talk about deleting previous app bundles. If a bundle is attached to any of the tracks, Google doesn't allow deactivating or deleting that bundle. The option to do so is only available when the bundle is not attached to any track.

You can refer to this: https://support.google.com/googleplay/android-developer/thread/215317396/how-do-i-remove-an-app-bundle?hl=en#:~:text=You%20can%20remove%20a%20bundle,of%20the%20app%20on%20it.

Keep in mind that you can change the version name or string to display it to users as you desire. For details on versioning, check out this: https://developer.android.com/studio/publish/versioning

paceHut
  • 1
  • 1
  • 1
0

Looks like there is some confusion in other answers with respect to changing the version code from version: 1.0.0+1 to version: 1.0.0+2 in pubspec.yaml file.

The following comments in pubspec.yaml file will help you understand the version code and version name in android:

# A version number is three numbers separated by dots, like 1.2.43
# followed by an optional build number separated by a +.
# Both the version and the builder number may be overridden in flutter
# build by specifying --build-name and --build-number, respectively.
# In Android, build-name is used as versionName while build-number used as versionCode.

Therefore, if you have version: 1.0.0+2, it means your versionName is 1.0.0 and versionCode is 2.

-1
  1. Change the version code
  2. Go to the other settings and change the bundle version code as well
General Grievance
  • 4,555
  • 31
  • 31
  • 45
Look Dev
  • 1
  • 1
  • 3
    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
-1

For Flutter there are 2 locations where you need to change version number and version code.

  1. In pubspec.yaml
    enter image description here
  2. In android/app/build.gradle
    enter image description here

Let me know if there is any problem.

Sanny khan
  • 177
  • 1
  • 1
  • 7