Ionic build adds 8 to version code

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.

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?

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.

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

It is very possible that versionCode is not on the list of forwarded parameters. You might want to open an issue about that at Issues · ionic-team/ionic-cli · GitHub

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?

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.

Opened an issue and got the following solution

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

1 Like