How to change version code in AndroidManifest.xml using Cordova 3.6.4

Mandeep Pasbola picture Mandeep Pasbola · Dec 18, 2014 · Viewed 10.9k times · Source

I am trying to change the version code in AndroidManifest.xml. I am using Cordova 3.6.4.

As per the docs I am updating it in the config.xml but it is not reflecting in the AndroidManifest.xml after the build.

Config.xml

<widget id="" versionCode="6" version="2.0.2" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">

AndroidManifest.xml after build

<manifest android:hardwareAccelerated="true" android:installLocation="auto" android:versionCode="20002" android:versionName="2.0.2" package="" xmlns:android="http://schemas.android.com/apk/res/android">

Answer

AAhad picture AAhad · Dec 18, 2014

As per Cordova API docs:

Both, Android and iOS support a second version string (or number) in addition to the one visible in app stores, versionCode for Android and CFBundleVersion for iOS.

Below is an example that explicitly sets versionCode and CFBundleVersion

<widget id="io.cordova.hellocordova"
  version="0.0.1"
  android-versionCode="7"
  ios-CFBundleVersion="3.3.3">

If alternative version is not specified, the following defaults will be used:

// assuming version = MAJOR.MINOR.PATCH-whatever
versionCode = PATCH + MINOR * 100 + MAJOR * 10000
CFBundleVersion = "MAJOR.MINOR.PATCH"