balu k
balu k

Reputation: 5068

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

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

Upvotes: 201

Views: 195916

Answers (28)

Omarname
Omarname

Reputation: 31

The problem is with the version code (the number after the + symbol), not the version name (the numbers before it). In Flutter/Android, the version code has to be unique and higher than any previous version you've uploaded to the Play Console.

No matter if it’s a major, minor, or patch update, the build number (version code) always needs to increase. This is because the Play Console relies on it to track releases and make sure updates are installed in the right order.

Upvotes: 0

Michael Soliman
Michael Soliman

Reputation: 2818

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 pushing an 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 containing all the previous app bundles you uploaded will show. Delete the one with the clashing bundle version and you're good to go.

Edit: If there is no option for Delete app build delete your releases from production tab.

Hope that solves your problem.

Upvotes: 186

Prawesh Panthi
Prawesh Panthi

Reputation: 358

There are two reason you got this issue in Play console.

Case 1 - You already had an app in Play Store and while updating new version of apk or abb in play console you got this issue.

Solution For This : Go to file name pubspec.yaml it would look like this version : 1.0.0+1 enter image description here

Here this +1 is the version of your apk you need to update it to +2 this is because play console need to reconize the new version of apk so each time you make any changes in your app and publish it again you need to update to +1,+2,+3 .. so on.

Like This

enter image description here

CASE 2 : You were about to publish another version in playstore you uploaded in play console but didnt fully Submit all your changes in play console. So the uploaded apk or abb goes on Play console draft you need to remove it for this

**Solution For Case 2 :**Play Console Dashboard and on Left side There is App Bundle Explorer or you can simply search App bundle Explorer

enter image description here If you get Delete app Bundle here you can delete it as it will solve your problem. enter image description here

If you didnt get it You can do this.

enter image description here

If you didnt get Delete app bundle button there you need to delete the draft from releases overview on Left side there is releases overview

enter image description here

and go tot releases tab and discard releases the last history enter image description here

If you discard this release the you will get delete app bundle button on App Bundle Explorer enter image description here

If it solves your problem Glad to know . Dont forget to upvote.

Upvotes: 10

ahmnouira
ahmnouira

Reputation: 3431

For flutter project you can change this in your pubspec.yaml file

version: 1.0.1+2

Rebuild again and this will give in your android/local.properties file

flutter.versionName=1.0.1
flutter.versionCode=2

Upvotes: 0

Manjunath Karamudi
Manjunath Karamudi

Reputation: 100

At First goto Gradle.build file in root folder of your Project find Version Code Change it to anything that is not previously used or even adding a Decimal(.) Symbol (as for me this was the Problem). Below is how my Project's Gradle.build defaultConfig is.

defaultConfig {
    applicationId = "com.SK.filedownloader"
    minSdk = 24
    targetSdk = 34
    versionCode = 10200
    versionName = "1.2"
    testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
}

(Change your Version code As you want but keep it Professional for future Updates and in VersionName you can add Version Number with Decimal)

Delete if any existing version is in Draft and create a new Publish Request, Delete existing version going to App Bundle explorer > select App version and delete the version with the option available.

Upvotes: 0

AnR
AnR

Reputation: 2225

I came across the same issue and ultimately found a neat solution. I changed it in pubspec.yaml as follows:

version: 0.0.2+2

This gave me these number in local.properties:

flutter.versionName=0.0.2
flutter.versionCode=2

In fact pubspec.yaml describes it as follows:

# The following defines the version and build number for your application.
# 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.
# Read more about Android versioning at https://developer.android.com/studio/publish/versioning

Upvotes: 0

Ahmed Saad
Ahmed Saad

Reputation: 175

if it's second time publish app

then increase your version code in android studio.

if you already increased version code

then it's already saved as a draft, go to release section > App Bundle Explorer > select specified version code -> delete app bundle (top right).

now feel free to create another release

Upvotes: 5

Gibo
Gibo

Reputation: 31

For React Native: Go to and open android>app>build.gradle

Change to higher number version. versionCode 2 versionName "2.0"

Upvotes: 0

Vicky Leekha
Vicky Leekha

Reputation: 61

local.properties

for flutter change here in local properties file

Upvotes: 2

Shamxeed
Shamxeed

Reputation: 422

This is happening because you have already uploaded a bundle with the same version so you don't need to upload the same thing repeatedly. So in my case, I used Add from library instead of upload then I selected the bundle I uploaded already and Yay!! I'm good to go!!!

Upvotes: 0

Dhruv Varshney
Dhruv Varshney

Reputation: 1

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.

Upvotes: 0

Sanny khan
Sanny khan

Reputation: 393

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.

Upvotes: -1

paceHut
paceHut

Reputation: 41

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

Upvotes: 1

Gamingman93
Gamingman93

Reputation: 1

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)

Upvotes: 0

Murat K.
Murat K.

Reputation: 952

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.

Upvotes: 3

BorisD
BorisD

Reputation: 1824

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

Upvotes: 0

Mart-Jan
Mart-Jan

Reputation: 67

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.

Upvotes: 3

Jeevan Pawar
Jeevan Pawar

Reputation: 3

change version code here please check the imageenter image description here

Upvotes: 0

Priyansh jain
Priyansh jain

Reputation: 1422

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.

Upvotes: 0

Karolina Hagegård
Karolina Hagegård

Reputation: 1387

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.

Upvotes: 1

balu k
balu k

Reputation: 5068

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

Upvotes: 89

Nsamba Isaac
Nsamba Isaac

Reputation: 495

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

Upvotes: 2

adarsh
adarsh

Reputation: 531

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.

Upvotes: 14

serraosays
serraosays

Reputation: 7869

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.

Upvotes: 9

hexhad
hexhad

Reputation: 1303

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 ✌😊

Upvotes: 43

Ryosuke Hujisawa
Ryosuke Hujisawa

Reputation: 2872

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

Upvotes: 0

Titas Černiauskas
Titas Černiauskas

Reputation: 1446

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

Upvotes: 111

Len_X
Len_X

Reputation: 873

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

Upvotes: 22

Related Questions