[android] Upload failed You need to use a different version code for your APK because you already have one with version code 2

According to this answer How to solve "Your APK's version code needs to be higher than 2." in Google Play's Developer Console? I have just changed the version code from 2 to 3 and it failed to upload the build.

This is my old manifest before I uploaded the apk

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="mypackage name"
    android:installLocation="auto"
    android:versionCode="28"
    android:versionName="1.0028" >

    <uses-sdk
        android:minSdkVersion="8"
        android:targetSdkVersion="19" />
        .....

here is the new version code which I have to upload on android developer console. See my menifest

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="mypackage name"
    android:installLocation="auto"
    android:versionCode="2"
    android:versionName="2.0001" >

    <uses-sdk
        android:minSdkVersion="8"
        android:targetSdkVersion="19" />
        ......

I dont know whats the issue. Any help? enter image description here

This question is related to android apk

The answer is


I kept getting same error again and again,

Finally I uploaded the apk file manually using Google Play Console as shown in screen shot.

Under App Release, You select the button "CREATE RELEASE" shown in the screen shot and upload your apk file from /android/app/bin/build/outputs/apk/release/app-release.apk

enter image description here


In my case I had something like this in my AndroidManifest,

      javaCompileOptions {
        annotationProcessorOptions {
            arguments = [
                    'androidManifestFile': 'app\\build\\intermediates\\merged_manifests\\debug\\processDebugManifest\\merged\\AndroidManifest.xml'
            ]
        }
   }

here the 'androidManifestFile' location is wrong, changed it to

"androidManifestFile": "$projectDir/src/main/AndroidManifest.xml".toString()

everything worked


This seems because you have already uploaded APK file of version 3 to Google Play Store. And again you are uploading apk with same version. So this issue has been occurred.

So for solution you need to change your version name and version code (increment with 1)and run application once and after export it upload to Google Play.


(For Flutter App) You need to use a different version code for your APK or Android App Bundle because you already have one with version code 1.

Don't be panic...

You need to change in Flutter Version from pubspec.yaml file and Version Code from local.properties file.

First go to your pubspec.yaml file. The first three lines should be name, description and version of App.

Before Release -

For you the version might look something like this:

version: 1.0.0+1

So before creating an apk for release (for update your exiting app on Google Play Console i.e for new update) make sure you increment this number by 1. (You should increment it as there's no requirement on increment step) .

Solution

Just change that version to (As per your need )

version: 1.0.1+2

And Second if

flutter.versionCode in Project -> android -> local.properties is

flutter.versionCode=1 then change it or upgrade it to the flutter.versionCode=2 or any other greater number than previous code.

And finally release the app as per documentation.


If you get this error for your Flutter App's Android APK, in your app/build.gradle file under defaultConfig {}

comment out

versionCode flutterVersionCode.toInteger()
versionName flutterVersionName

and add

versionCode 2
versionName "2"

or "previous version code" + 1.


In my case it a simple issue. I have uploaded an app in the console before so i try re uploading it after resolving some issues All i do is delete the previous APK from the Artifact Library


If you're using Building Standalone Apps with Expo, the versionCode error might creep up owing to the fact that the standard app.json config only has a reference to the version property.

I was able to add a versionCode property under android as follows:

Sample App.json

{
  "expo": {
    "sdkVersion": "29.0.0",
    "name": "App Name",
    "version": "1.1.0",
    "slug": "app-name",
    "icon": "src/images/app-icon.png",
    "privacy": "public",
    "android": {
      "package": "com.madhues.app",
      "permissions": [],
      "versionCode": 2 // Notice the versionCode added under android.
    }
  }
}

Detailed documentation: https://docs.expo.io/versions/v32.0.0/workflow/configuration/#versioncode


In my app/build.gradle file , version code was like this:-

build.gradle(app module) file

In place of versionCode flutterVersionCode.toInteger() , i replaced it with as versionCode 2


In Flutter

Update version:1.0.0+1 in pubspec.yaml.

The default version number of the app is 1.0.0. To update it, navigate to the pubspec.yaml file and update the following line:

version: 1.0.0+1

+1 (the number after the +) represents the versionCode such as 1, 2, 3, etc.

So increase it one by one, like this

version: 1.0.1+2

The version number is three numbers separated by dots, such as 1.0.0 in the example above, followed by an optional build number such as 1 in the example above, separated by a +.

Both the version and the build number may be overridden in Flutter’s build by specifying --build-name and --build-number, respectively.

In Android, build-name is used as versionName while build-number used as versionCode. For more information, see Version your app

After updating the version number in the pubspec file, run flutter pub get from the top of the project, or use the Pub get button in your IDE. This updates the versionName and versionCode in the local.properties file, which are later updated in the build.gradle file when you rebuild the Flutter app.


Just as Martin Konecny's answer said, you need to change the versionCode to something higher.

Your previous version code was 28. it should be changed to 29.

According to the document on the android developer website. a version code is

An integer value that represents the version of the application code, relative to other versions.

So it should be related(by related I mean higher) to the previous versionCode as noted by the document:

you should make sure that each successive release of your application uses a greater value.

As mentioned again in the document

the android:versionCode value does not necessarily have a strong resemblance to the application release version that is visible to the user (see android:versionName, below)

So even though this is the release 2.0001 of your app, it does not necessarily mean that the versionCode is 2.

Hope this helps :)


In Android Studio 1.1.0, change versionCode in build.gradle for Module: app and don't necessarily change versionName:

android {
...
    defaultConfig {
...
        versionCode 3
        versionName "1.0"
    }
...
}

For people who use Android Studio the problem may be solved by editing versionCode and versionName in build.gradle instead of AndroidManifest.xml.

e.g.

defaultConfig {
    applicationId "com.my.packageId"
    minSdkVersion 15
    targetSdkVersion 22
    versionCode 2      <-- change this
    versionName "2.0"  <-- change this
}

if you are using phonegap / cordova applications, just edit your config.xml and add the android-versionCode and version in the widget.

<widget id="com.xxx.yyy" version="1.0.1" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0" android-versionCode="100001" version="1.0.1">


If you're using Android Studio, you could go:

Build -> Edit Flavors

And change the Version Code and Name from there.

enter image description here


if you are using ionic framework, go to config.xml file and change the "version" attribute in the "widget" tag. increase the version number. then rebuild, sign and upload ur apk to play store. that fixed my problem.


I received the same error while uploading a flutter app to playstore simply change the version code in pubspec.yaml worked for me. may be try changing the version code e.g from +1 to +2 and then rebuild the apk using

flutter build apk --split-per-abi 

and upload all the apk's to the playstore for your users. Next time when you want to push an update make sure to update the version code to +3 and so on.

Note: that the version code and version name are different you can see that in android/local.properties file. e.g version: 1.0.0+2

version is 1.0.0 and verison code is +2


This error appears when you try to upload an apk that has same version values as the one already on playstore.

Just change the following in your build.gradle file => versionCode and versionName

defaultConfig {
    applicationId "com.my.packageId"
    minSdkVersion 16
    targetSdkVersion 27
    versionCode 2      <-- increment this by 1
    versionName "2.0"  <-- this is the version that shows up in playstore, 
                           remember that the versioning scheme goes as follows.
                           first digit = major breaking changes version
                           second digit = minor changes version
                           third digit = minor patches and bug fixes.
                           e.g versionName "2.0.1"
}

Sometimes the PlayStore encounters a bug when you upload an APK during a Release creation, and you are stuck because you cannot upload the same APK again, for the current draft release. You get the error "Upload failed..."

The solution is to go to the Artifact library menu, under Release management and to delete the draft artifact. Once this is done, you will be able to upload the APK again, and to finish your release.

Hope it will help others...

Ben