Skip to content

Instantly share code, notes, and snippets.

@florinmuscalu
Created February 4, 2021 21:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save florinmuscalu/10e1d6c76d012c0b64ec4b39460edbf6 to your computer and use it in GitHub Desktop.
Save florinmuscalu/10e1d6c76d012c0b64ec4b39460edbf6 to your computer and use it in GitHub Desktop.
android {
...
def versionFile = file('version.properties')
Properties prop = new Properties()
if (versionFile.canRead()) {
prop.load(new FileInputStream(versionFile))
}
else {
prop['VERSION_CODE']='0'
}
def code = prop['VERSION_CODE'].toInteger() + 1
prop['VERSION_CODE']=code.toString()
prop.store(versionFile.newWriter(), null)
defaultConfig {
...
versionCode code
versionName "1.0"
}
...
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment