Ionic/Cordova Android APK Versioning Issue

While trying to submit our ionic app to the Google play store we began getting the following error:


Screen Shot 2016-09-02 at 1.23.28 PM


This seemed weird because the version was set to “0.0.1” on the config.xml widget tag and the apk was set to version 18 for some reason.


`<widget id=”[app id was here]” version=”0.0.1″ xmlns=”” xmlns:cdv=”″ xmlns:gap=”″>`


We tried a couple of possible solutions:
– Adding `android-VersionCode=”[Version]”` to the widget tag
– Manually adding `android:versionCode”[Version]”` directly to the android manifest
– Changing the version value on the widget tags


All of these failed and we would find out the version was still 18 by trying to upload to the play store an getting the same error message. We later found that running `apktool d your-app-name.apk` generated a directory with a yml file called `apktool.yml` which specified the version code making it easier to find out if the version was updated.


During this process we added the cordova-plugin-crosswalk-webview thinking we needed this for some openssl issues and maybe the versioning issue. We added this by running `ionic browser upgrade`


We later found out that the order of the attributes on the widget tag affected the apk’s version behavior. (Possible Ionic/Cordova bug?)
This did not work:


Screen Shot 2016-09-02 at 1.29.54 PM



But this did:


Screen Shot 2016-09-02 at 1.30.12 PM




After hours of investigating the issue we found some anomalies on the android platform build.gradle. Depending on the `minSdkVersion` it would add an amount to the version code

Example of some of the logic on the build.gradle:

if (Boolean.valueOf(cdvBuildMultipleApks)) {

productFlavors {

armv7 {

versionCode defaultConfig.versionCode + 2

ndk {

abiFilters “armeabi-v7a”, “”



x86 {

versionCode defaultConfig.versionCode + 4

ndk {

abiFilters “x86”, “”



all {

ndk {

abiFilters “all”, “”




} else if (!cdvVersionCode) {

def minSdkVersion = cdvMinSdkVersion ?: privateHelpers.extractIntFromManifest(“minSdkVersion”)

// Vary versionCode by the two most common API levels:

// 14 is ICS, which is the lowest API level for many apps.

// 20 is Lollipop, which is the lowest API level for the updatable system webview.

if (minSdkVersion >= 20) {

defaultConfig.versionCode += 9

} else if (minSdkVersion >= 14) {

defaultConfig.versionCode += 8




Turns out this was generated because of the cordova-plugin-crosswalk-webview plugin. We reverted this by running `ionic browser revert android` and building the app again. This build.gradle logic was removed afterwards thus fixing this weird versioning issue.


After this we set the version to 1.0.200 and versionCode to 200 to start “fresh” with a rounded up version since the current app was at version 198 at this point and we got the correct version as we expected.
Hope this post helps anyone if having similar issues like this one.

Add A Comment

Your email address will not be published. Required fields are marked *