versionCode not updating on android APK

I released my app, and now I need to upload some bug fixes. I use ionic package release android to get my APK, but the APK’s version code doesn’t change even though I changed it in the AndroidManifest.xml

android:versionCode="2"

Any way to properly change this?

1 Like

This version code you change on config.xml file.

2 Likes

This is configured on the “widget” element of your config.xml.

Example:

<?xml version="1.0" encoding="UTF-8" ?>
    <widget xmlns   = "http://www.w3.org/ns/widgets"
        xmlns:gap   = "http://phonegap.com/ns/1.0"
        id          = "APP ID" 
        version     = "2.1.0"
		versionCode = "307" 		
		>
2 Likes

I was using “ionic package release android” to prepare my apk, but it wouldn’t update the versionCode. I tried putting the versionCode in config.xml, but that didn’t work, so I just buld the apk myself now.

In Cordova 3.5.x the param in config.xml is: android-versionCode.

Sample:

widget id=“APP ID” version=“0.0.0.1” android-versionCode=“3”

8 Likes

Did you ever figure anything out?

Version code is one that will be present at config.xml. once we create a platfrom using ::
ionic platform add android
then at platform folder–>android–> you will find android manifest.xml file
open in notepad there android:versionCode=“601” android:versionName="0.6.1"
here 601 is version code which should be changed before generating apk

android:versionName=“0.6.1” is the name that is displayed at user side at setting option
version 0.6.1
this versionname is optional

**how to set version code in ionic in manifest file i already change the version code but when i build its change again to one . kindly
tell how to process this because i am new in this . kindly tell thanks
in advance .want to update app on play store but when try this every time i am getting this error :-
You need to use a different version code for your APK because you already have one with version code 1.

<?xml version='1.0' encoding='utf-8'?>
<manifest android:hardwareAccelerated="true" android:versionCode="2" android:versionName="1.1" package="com.ionicframework.chalisa863645" xmlns:android="http://schemas.android.com/apk/res/android">
    <supports-screens android:anyDensity="true" android:largeScreens="true" android:normalScreens="true" android:resizeable="true" android:smallScreens="true" android:xlargeScreens="true" />
    <uses-permission android:name="android.permission.INTERNET" />
    <application android:hardwareAccelerated="true" android:icon="@drawable/icon" android:label="@string/app_name" android:supportsRtl="true">
        <activity android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale" android:label="@string/activity_name" android:launchMode="singleTop" android:name="MainActivity" android:theme="@android:style/Theme.DeviceDefault.NoActionBar" android:windowSoftInputMode="adjustResize">
            <intent-filter android:label="@string/launcher_name">
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <activity android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize" android:name="com.google.android.gms.ads.AdActivity" android:theme="@android:style/Theme.Translucent" />
    </application>
    <uses-sdk android:minSdkVersion="16" android:targetSdkVersion="23" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
</manifest>

That file is generated, change config.xml in your project root instead.

if you really dont want to generate Version code(60002) automatically based on Version(6.0.2) then you can pass your user defined customized version code from config.xml itself like this -
<widget id=“xxx.xxxx.xxxandroid-versionCode=“60005” version=“6.0.2” xmlns=“http://www.w3.org/ns/widgets” xmlns:cdv=“http://cordova.apache.org/ns/1.0”>

Then it will get updated automatically in android manifest file also.

2 Likes

this is the best answer. setting up your config file properly will make sure your numbers carry to every location they need to be carried over too

bro there is command while you built the ionic project mention the version code and you do not have to mention it any where .

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

for the reference Please Visit This

None of these are working for me.

My config.xml has

<widget android-versionCode="2" id="xx.xx.xx" ios-CFBundleVersion="2" version="0.0.4" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">

My full build script is:

env ENV=prod ionic cordova build android --prod --release -- -- --versionCode=2 --gradleArg=-PcdvVersionCode=2

Environment info:

Ionic:

   ionic (Ionic CLI)  : 4.2.1
   Ionic Framework    : ionic-angular 3.9.2
   @ionic/app-scripts : 3.2.0

Cordova:

   cordova (Cordova CLI) : 8.1.2 (cordova-lib@8.1.1)
   Cordova Platforms     : android 7.1.4, browser 5.0.3, ios 4.5.5
   Cordova Plugins       : no whitelisted plugins (19 plugins total)

System:

   Android SDK Tools : 26.1.1 (/Users/<username>/Library/Android/android-sdk)
   ios-deploy        : 2.0.0
   NodeJS            : v8.11.3 (/usr/local/bin/node)
   npm               : 5.6.0
   OS                : macOS
   Xcode             : Xcode 10.1 Build version 10B61

But the output of “aapt dump badging appname.apk” is still
versionCode='1' versionName='0.0.3' platformBuildVersionName='0.0.3'

Any updates to this problem?