I am currently working on a Cordova project and had the problem that 8 was appended mysteriously to the versionCode of my project. For example: My original Version code was
For those who want to keep the end '8', I have write a after_prepare hook to make it easy, no need to maintain the android-versionCode in config.xml manually mentioned by @ChilledFlame.
Note: if you do not keep the end '8', when you submit your app to the appstore, your android version code is smaller then previous which built by Cordova 5, you may encounter "version code downgrade issue".
create a file under folder hooks/after_prepare/
, add the following code.
#!/usr/bin/env node
var path = require('path');
var fs = require('fs');
var xml2js = require('xml2js');
function xmlFileToJs(filename, cb) {
var filepath = path.normalize(path.join(__dirname, filename));
fs.readFile(filepath, 'utf8', function (err, xmlStr) {
if (err) throw (err);
xml2js.parseString(xmlStr, {}, cb);
});
}
function jsToXmlFile(filename, obj, cb) {
var filepath = path.normalize(path.join(__dirname, filename));
var builder = new xml2js.Builder();
var xml = builder.buildObject(obj);
fs.writeFile(filepath, xml, cb);
}
var androidManifestRPath = '../../platforms/android/AndroidManifest.xml';
xmlFileToJs(androidManifestRPath, function(error, data) {
var config = data;
config.manifest.$['android:versionCode'] += '8';
jsToXmlFile(androidManifestRPath, config)
});
or download from this link: append_8_to_version_code.js