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.
<
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"
}
...
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)"
Please see attached snap of Android Studio which should help.
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.
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."
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