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?
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."
Please see attached snap of Android Studio which should help.
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>
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">
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 :)
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.
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
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.
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.
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"
}
...
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
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 {
}
}
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.
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.
easy way to resolve it is click on Build > Edit Flavors...
change version code and version name
click ok and done
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)"