8

In the mobile-config.js I have specified following

App.info({
    .....
    version: '1.0.8',
    ....
});


App.setPreference('android-versionCode', '9');

Accordingly when I build apk it should have versionCode set to 9 and version name to "1.0.8', but in my case versionCode is being set to "10008" while version name is correctly shown as "1.0.8".

Is there something wrong in my config? Is there different method to version Code?

Pavan Kumar
  • 1,715
  • 1
  • 24
  • 48
  • I'm using meteor 1.1.0.3 and find that using `version: '0.0.10'` generates an `android-versionCode=10` in the _AndroidManifest.xml_, so you can use this setting (without `App.setPreference('android-versionCode', '9');`). Hope it helps. – Oscar Saraza Sep 09 '15 at 16:31
  • The 8 at the end of your versionCode is a [bug still in Cordova](http://stackoverflow.com/questions/32951375/why-does-cordova-phonegap-append-8-to-my-android-version-code) – Martin Kool May 27 '16 at 11:46

4 Answers4

9

As of Meteor 1.4.2 you can specify buildNumber in App.info within the mobile-config.js file. See example below

App.info({ id: '', name: '', description: '', version: '0.5.6', buildNumber: '5060', author: '', email: '', website: '' });

sathish
  • 121
  • 1
  • 3
3

You can override meteor build files and setting by creating a top level folder called /cordova-build-override/, read more here errr, GitHub is down, I will post a link when it is back.

Solution is to pass Android build settings to build-extras.gradle. You can read more here Android Shell Tool Guide.

Create /cordova-build-override/platforms/android/build-extras.gradle. The Android Version Name will be set in mobile-config.js but the Version Number (Integer) will be set by this gradle file.

cdvVersionCode = '10'
android {
  lintOptions {
      disable 'MissingTranslation'
      disable 'ExtraTranslation'
  }
}
benstr
  • 652
  • 4
  • 16
0

I haven't found a good answer for this yet but by importing the project into Android Studio and editing project/manifests/AndroidManifest.xml you can change the version code. You have to rebuild of course. It appears android-versionCode sets the version code of the CordvaLib project but not project. The Gradle build script will still add an 8 to the end of it though. You can find where it does that pretty easily if you want to tweak it (Search for cdvVersionCode). Seems stupid to have to do any of this though and I just wanted to get something to the beta testers.

Justin Driscoll
  • 654
  • 4
  • 10
0

I may be pretty late to the party here, but the simplest solution is to set the build number in your App.info({ ... }) at the top of the mobile-config.js.

bigmadwolf
  • 3,419
  • 3
  • 30
  • 44