Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get Cordova 3.4.0 to set Android version name/code on build?

I am currently using Cordova 3.4.0 and the CLI to build my project to target android using the command:

cordova build android 

OR

cordova build android --release 

My config.xml has the following specified:

<widget id="com.example.myapp"          version="0.0.3"          versionCode="2"          ...         > </widget> 

The resulting AndroidManifest.xml in myapp/platforms/android does not get updated with the version and version code specified in config.xml. It stays as the default:

<manifest          android:versionCode="1"          android:versionName="1.0"         ... </manifest> 

Is this a bug? Or is there some other way I should specify the versionCode and versionName for Android in the config.xml? Even maybe, is there a hook I can use to update AndroidManifest.xml with the correct version before build?

I would rather not have to update this manually each time I want it to change as:

  1. It is error prone and fiddly
  2. It wont be an obvious thing to change for unfamiliar developers
  3. None of the platform folders are stored in source control

For these reasons I would like the version numbers to be set in the config.xml. Any ideas?

Thanks

like image 947
Steven Anderson Avatar asked Apr 11 '14 01:04

Steven Anderson


People also ask

How do I know my Android cordova version?

Requirements and Support. Please note that the versions listed here are for Cordova's Android package, cordova-android, and not for the Cordova CLI. To determine what version of Cordova's Android package is installed in your Cordova project, run the command cordova platform ls in the directory that holds your project.


1 Answers

At last with Cordova 3.5.0-0.2.4 I added this attribute to the <widget> node config.xml

 android-versionCode="10" 

and the AndroidManifest.xml was properly updated to

 android:versionCode="10"  
like image 136
Diogo Avatar answered Sep 21 '22 12:09

Diogo