How to auto-increment cocos2d-x android build number
from: http://stackoverflow.com/questions/21405457/autoincrement-versioncode-with-gradle-extra-properties
To auto-increment the build number of an android app, following gradle code can be used: proj.android-studio/app/build.gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 22
buildToolVersion "22.0.1"
// get version/build numbers
def versionPropsFile= file('version.properties')
if (versionPropsFile.canRead()) {
def Properties versionProps= new Properties()
versionProps.load(new FileInputStream(versionPropsFile))
def version = versionProps['VERSION']
def build= versionProps['BUILD'].toInteger() + 1
versionProps['BUILD']= code.toString()
versionProps.store(versionPropsFile.newWriter(), null)
defaultConfig {
applicationId "kr.jachong.newgame"
minSdkVersion 10
targetSdkVersion 22
// apply version/build numbers
versionCode build
versionName version
....
}
} else {
throw new GradleException("Could not read version.properties")
}
...
}
To enable above script, proj.android-studio/app/version.properties file should be prepared.
VERSION 1.0 BUILD 1
2 thoughts on “How to auto-increment cocos2d-x android build number”