Setting Android version code in Ionic 2 / Cordova
Asked Answered
A

2

19

I'm completely stuck with a crazy issue. I'm not able to publish an update of my app in Google Play store because current version code is 101002.

Now, I don't understand how that code was generated. In my config.xml I tried using the following versions:

1.3
1.3.1
1.3.1.1

but every time it generates a version code like:

10300
10310
10311

that is always lower than the current version code: 101002

I also tried to build using the following command:

ionic cordova build android --prod --release -- -- --versionCode=103020

but it doesn't work

I can't manually set the version code of the Manifest file because it's generated by ionic 2 build process. Any idea?

Arcadian answered 6/9, 2017 at 7:12 Comment(0)
P
57

You can specify a custom version-code in config.xml. Add the following property to the <widget> element (the root element): android-versionCode="101003".

This is an example of a full <widget> tag with more properties that are probably useful:

<widget android-versionCode="100" id="your.bundle.id" ios-CFBundleVersion="1.0.0" version="1.0.0" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
  • version is the version displayed in the app stores, can stay the same across different builds
  • android-versionCode this is used by Google-Play to differentiate between your builds, must always be higher than the previous one
  • CFBundleVersion is used by iTunesConnect to differentiate your builds, must always be higher than the previous one
  • id is where you define the bundle identifier of your app, this must always stay the same
Phrygian answered 6/9, 2017 at 8:42 Comment(2)
Glad to help! Here is the documentation for config.xml if you need to lookup something else: cordova.apache.org/docs/en/latest/config_refPhrygian
How it can be done automatically integrate with CI/CD GItlab pipeline?Bondholder
H
2

If you compile your project with Android Studio, you can change it in the App-> Manifests-> AndroidManifest.xml folder

screenshot

Hellbent answered 29/1, 2020 at 11:59 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.