Ionic build adds 8 to version code


#1

I have the following in my config.xml

<widget android-versionCode="301" version="3.0.1"

After building the app using
ionic cordova build android --release

And I check the version code using
aapt dump badging myappPath.apk

I see that the version code is 3018 (8 is suffixed).

After searching the web I got this answer here

So I tried running the following command.
ionic build --release android -- --versionCode=3

Still getting the same result of 8 being suffixed.


How can i get the versionCode to use with update function?
#2

This is not done by Ionic but by Cordova.

Probably something here:

What is your ionic info?
Any manual changes on the generated Android project?


#3

My ionic info is as follows:


cli packages: (C:\Users\prantikv\AppData\Roaming\npm\node_modules)

    @ionic/cli-utils  : 1.12.0
    ionic (Ionic CLI) : 3.12.0

global packages:

    cordova (Cordova CLI) : not installed

local packages:

    @ionic/app-scripts : 3.0.0
    Cordova Platforms  : android 5.1.0
    Ionic Framework    : ionic-angular 3.7.1

System:

    Android SDK Tools : 25.2.5
    Node              : v6.11.3
    npm               : 5.4.2
    OS                : Windows 10

Misc:

    backend : pro

I have not made any changes to the Android Project nor I intend to do so.

A thing to note here is that the following does not work
ionic build --release android -- --versionCode=3
while the following does work
cordova build --release android -- --versionCode=3

So it seems to be an ionic issue.


#4

This is pretty old, you should upgrade. Same for Cordova CLI probably if it is not on 7.0.1.


#5

It is very possible that versionCode is not on the list of forwarded parameters. You might want to open an issue about that at https://github.com/ionic-team/ionic-cli/issues


#6

Yes, the platform is old as I am purposefully targetting that platform. The cordova CLI is at 7.0.1.

I just assumed that all the cordova cli parameters were available under tha Ionic CLI as it run the cordova cli underneath.
But sadly it seem that is not the case.

Can you suggest any other way I can solve this from my end?


#7

Quickly create an issue, then a dev can tell you if this is indeed the problem or not.

If it is, run the cordova command directly after running an Ionic build.


#8

Opened an issue and got the following solution

ionic cordova build android --release -- -- --versionCode=3