Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@jensgreiner
Last active July 15, 2017 10:28
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 jensgreiner/97c0d84d3e19cfbe4d54c2451d80cecd to your computer and use it in GitHub Desktop.
Save jensgreiner/97c0d84d3e19cfbe4d54c2451d80cecd to your computer and use it in GitHub Desktop.
Add auto incremented versionCode using a properties file
/**
* Adds auto incremented versionCode number
* Found on stackoverflow
* see https://stackoverflow.com/a/25166200/1469260
*/
def Properties versionProps = new Properties()
def versionPropsFile = file('version.properties')
if (versionPropsFile.exists())
versionProps.load(new FileInputStream(versionPropsFile))
def code = (versionProps['VERSION_CODE'] ?: "0").toInteger() + 1
versionProps['VERSION_CODE'] = code.toString()
versionProps.store(versionPropsFile.newWriter(), null)
defaultConfig {
applicationId "com.example.android.miwok"
minSdkVersion 15
//noinspection OldTargetApi
targetSdkVersion 25
versionCode code
versionName "1.2." + code
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment