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

1

9

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">
Zwinglian answered 18/12, 2014 at 5:24 Comment(0)
B
17

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"
Babbittry answered 18/12, 2014 at 5:57 Comment(3)
@Babbittry I'm running into the same issue. I pasted my widget tag. But for some reason the android version code is using the alternate not specified calculation. Any suggestions? <widget id="org.app.app" version="0.1.4" android-versionCode="13" ios-CFBundleVersion="3.3.3" xmlns="w3.org/ns/widgets" xmlns:cdv="cordova.apache.org/ns/1.0">Cauline
@Babbittry I actually figured out the issue If your application has enabled the cdvBuildMultipleApks Gradle property (see Setting Gradle Properties), the version code of your app will also be multiplied by 10 so that the last digit of the code can be used to indicate the architecture the apk was built for. This multiplication will happen regardless of whether the version code is taken from the android-versionCode attribute or generated using the version. Be aware that some plugins added to your project (including cordova-plugin-crosswalk-webview) may set this Gradle property automatically.Cauline
For those who would like the Ionic Documentation regarding my comments [cordova.apache.org/docs/en/latest/guide/platforms/android/… Setting the Version Code in config.xml).Cauline

© 2022 - 2024 — McMap. All rights reserved.