How to solve "Your APK's version code needs to be higher than 2." in Google Play's Developer Console?

AndroidCordovaApk

Android Problem Overview


I'm getting this error when uploading my Phonegap app to the Google Play Developer Console:

> Your APK's version code needs to be higher than 2.

How can I fix this?

Android Solutions


Solution 1 - Android

If you're directly using Gradle, or indirectly through Android Studio:

I fixed it by editing the version number inside of the build.gradle file! There is a small banner at the bottom of the android.manifest file that says "these changes are being overwritten by the build.gradle file."

Solution 2 - Android

enter image description here

Please see attached snap of Android Studio which should help.

Solution 3 - Android

Increase the version code to 3 by changing versionCode in your AndroidManifest.xml:

<android xmlns:android="http://schemas.android.com/apk/res/android">
        <tool-api-level>10</tool-api-level>
        <manifest android:versionCode="3" android:versionName="0.1.1" android:installLocation="preferExternal"/>
        <uses-sdk android:maxSdkVersion="10" android:minSdkVersion="7" android:targetSdkVersion="10"/>
</android>

Solution 4 - Android

Use aapt to verify your APK version:

aapt dump badging myapp.apk

It will tell you to increase the versionCode in AndroidManifest.xml, e.g.

  <manifest android:versionCode="3">

Solution 5 - Android

Had the same problem and solved it by changing the following values in the build.gradle file in the Module: app

defaultConfig {
        applicationId //app package goes here
        minSdkVersion 10
        targetSdkVersion 21
        **versionCode 2
        versionName "1.1"**
        signingConfig //name of keystore goes here
    }

This is the way Android Studio keeps track of the versioning for each app.

Alternatively, for the noobs, you can access these settings by clicking on the settings of the app, and navigating to the Flavors tab. There you can amend certain settings such as the versionCode and the versionName.

Hope this helps :)

Solution 6 - Android

When you are ready to deploy your app to an APK, in JDeveloper go to Application -> Deploy -> New Deployment Profile. Set Profile Type to ADF Mobile for Android, pick a name and click OK. In the next window pick the Android options and change the Version Code. That's what Google Play didn't like (because you already had an app with the same version code). That's how I resolved this issue.

Solution 7 - Android

People at android and your users need to just keep track of all the updates so it's required for you to mention the version by updating versionCode and versionName

Here is how to fix the problem:

EARLIER

defaultConfig {
    applicationId "com.example.random.projectname"
    minSdkVersion 15
    targetSdkVersion 24
    versionCode 1
    versionName "1.0"
}

NOW

defaultConfig {
    applicationId "com.example.random.projectname"
    minSdkVersion 15
    targetSdkVersion 24
    versionCode 2
    versionName "1.0.1"
}

Remember

  • versionName is what is displayed at bottom of Long Description for the app's user

  • While versionCode is for developer's and google's need and has to be incremented by one always for every new versionName even when you change versionName from v1.0.5 to v1.0.6

Solution 8 - Android

I suppose that you already have a version 2 uploaded to your dev console. Simply increase the version code (note: NOT version name!) to 3, rebuild your APK and you are fine.

Solution 9 - Android

I had this issue for a while and it stumped me. I tried re-importing project. Taking the project into Android Studio from Eclipse. Everything. And what I found to work is that you have to increase the version code by 1 value. You don't have to change the version name. And before you export the apk file. Make sure you build the project at least once. So the new version code is realized.

Solution 10 - Android

I found that if you are using Android Studio, you need to update the version code in the build.gradle file. For example:

defaultConfig {
    applicationId "app.myapp"
    minSdkVersion 14
    targetSdkVersion 20
    versionCode 2
    versionName "1.0.0"
}

...

Solution 11 - Android

Had the same problem. Changing the version wasn't helpful. For Android builds you can add versionCode to your config.xml and state the version.

    xmlns:gap = "http://phonegap.com/ns/1.0"
    id        = "xxx.xxxxxx"
    versionCode = "415" 
    version   = "1.0.11">

Check http://docs.build.phonegap.com/en_US/3.1.0/configuring_basics.md.html#The%20Basics

Solution 12 - Android

In Android studio I was only able to get this to work by changing the versionCode in the app file.

android {
    compileSdkVersion 19
    buildToolsVersion '19.1.0'
    defaultConfig {
        applicationId 'xxxxxxxxxxxxxxx'
        minSdkVersion 14
        targetSdkVersion 19
        versionCode 3
        versionName '1.1'
    }
    buildTypes {
        release {
            runProguard false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    productFlavors {
    }
}

Solution 13 - Android

The solution for me was to edit config.xml and change the 'version' property.

I tried editing my AndroidManifest.xml (every version I could find) and changed the versionCode and versionName values. Some of the AndroidManifest.xml files were overwritten with the original values, some were not overwritten. Regardless, the apk version was remaining at '1'.

I looked in config.xml several times, but neither versionCode and versionName exist within. I finally decided to change the 'version' value in config.xml, rebuilt, and my apk now has the new, correct, version number.

In config.xml:

Old 'version' property: "version=0.0.1"

New 'version' property: "version=0.0.2"

It should be noted that I am not using Eclipse or Android Studio ... just a text editor and running a manual build. Now when I run

aapt dump badging [apk name]

I am seeing an updated versionCode and versionName... specifically, I see this:

versionCode='2' versionName='0.0.2'

...and I can now upload my apk successfully to the Play store once again.

Solution 14 - Android

appt dump badging myapp.apk

This command works in checking the built apk version. but to and old trick fixed this problem, even if I incremented the version. Try to clean the workspace and build again.

Solution 15 - Android

easy way to resolve it is click on Build > Edit Flavors...

enter image description here

change version code and version name

enter image description here

click ok and done

Solution 16 - Android

For my Cordova built app, the Gradle file didnt have the static code. It was picked using Android Manifest like this -

defaultConfig {
versionCode cdvVersionCode ?: Integer.parseInt("" + privateHelpers.extractIntFromManifest("versionCode") + "0")
applicationId privateHelpers.extractStringFromManifest("package")

if (cdvMinSdkVersion != null) {
    minSdkVersion cdvMinSdkVersion
}

}

I tried changing the version code in the manifest file, but no luck.

Not a good thing to do, but out of hurry I did this -

defaultConfig {
versionCode cdvVersionCode ?: (Integer.parseInt("" + privateHelpers.extractIntFromManifest("versionCode") + "0") + 2)
applicationId privateHelpers.extractStringFromManifest("package")

if (cdvMinSdkVersion != null) {
    minSdkVersion cdvMinSdkVersion
}

}

Note: For Cordova built apps, you need to make changes in the Gradle Scripts > File which says - "build.gradle (Module:android)"

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionkqwView Question on Stackoverflow
Solution 1 - Androiduser3546740View Answer on Stackoverflow
Solution 2 - AndroidVijayView Answer on Stackoverflow
Solution 3 - AndroidHamed BaatourView Answer on Stackoverflow
Solution 4 - AndroidkqwView Answer on Stackoverflow
Solution 5 - AndroidMichele La FerlaView Answer on Stackoverflow
Solution 6 - AndroidIvanView Answer on Stackoverflow
Solution 7 - AndroidSlick SlimeView Answer on Stackoverflow
Solution 8 - AndroidGoddchenView Answer on Stackoverflow
Solution 9 - AndroidRandolphView Answer on Stackoverflow
Solution 10 - Androiddroid-zillaView Answer on Stackoverflow
Solution 11 - AndroidBrunoMartinsView Answer on Stackoverflow
Solution 12 - Androiduser2848810View Answer on Stackoverflow
Solution 13 - AndroidPhrankView Answer on Stackoverflow
Solution 14 - AndroidCebu CM SolutionsView Answer on Stackoverflow
Solution 15 - Androiduser3663631View Answer on Stackoverflow
Solution 16 - AndroidLakshayView Answer on Stackoverflow