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

27,041

Solution 1

you have two ways doing 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, so it says that you can't use the same version because it already sees another one with the same version name. you can fix that by going to release section, go to app bundle explorer, in the top right you should see a dropdown button for you app version, click on it, 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's your problem

Solution 2

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

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

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

Solution 5

Goto Pubspec.yaml file and find version key and Change the value after the + sign.

Example: in your pubspec.yaml file your version is like this version: 1.0.0+1 then change it to version: 1.0.0+2

Share:
27,041
balu k
Author by

balu k

Updated on December 08, 2021

Comments

  • balu k
    balu k over 2 years

    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

  • Len_X
    Len_X almost 3 years
    This is not a maintainable solution.
  • Michael Soliman
    Michael Soliman almost 3 years
    @Len_X this solution is only for pre-releasing, if you release your app, then your solution is the right way
  • ce-loco
    ce-loco almost 3 years
    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.
  • mgalgs
    mgalgs over 2 years
    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...
  • Ryosuke Hujisawa
    Ryosuke Hujisawa over 2 years
    and you need % flutter build appbundle --release again
  • serraosays
    serraosays over 2 years
    Super confusing to keep track of.
  • Brandon Essler
    Brandon Essler over 2 years
    @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?
  • Osh Mansor
    Osh Mansor over 2 years
    @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.
  • Jay N
    Jay N over 2 years
    I can't see the "delete" option when I click on the dropdown, next to app version. Does it still work?
  • gildniy
    gildniy over 2 years
    This is what I was looking for as I had to update the bundle before publishing it.
  • Aditya Peshave
    Aditya Peshave over 2 years
    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)....
  • charles young
    charles young about 2 years
    This is the simplest way if you are not ready to increment the version number in your bundle. It worked for me!
  • Karolina Hagegård
    Karolina Hagegård almost 2 years
    Weird that this works for you!... This has never worked for me. Also "version" and "version code" are not the same thing so... your SDK automatically increments your version code when you change your version name? 🤔
  • Karolina Hagegård
    Karolina Hagegård almost 2 years
    However, there is a point with version code numbers! 🙂 If you do it this way, you're missing that point.
  • Karolina Hagegård
    Karolina Hagegård almost 2 years
    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
    Karolina Hagegård almost 2 years
    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.
  • balu k
    balu k almost 2 years
    The number after the "+" sign is version code
  • Karolina Hagegård
    Karolina Hagegård almost 2 years
    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.
  • Alexa289
    Alexa289 almost 2 years
    @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: i.stack.imgur.com/oFK0L.png
  • Edward Falk
    Edward Falk almost 2 years
    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"
  • midnite
    midnite almost 2 years
    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.
  • Mahmoud Mousa Hamad
    Mahmoud Mousa Hamad almost 2 years
    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. :)