Add version.properties file to your Android Project

Change version name and version code from one file and reflect the changes on all the product flavors

Image Credits: https://www.bantex.co.za/product/polypropylene-lever-arch-files/

Step1:

Version properties file

Step2:

Version properties file

Step3:

def versionPropsFile = file('version.properties')
Properties versionProps = new Properties()

if (versionPropsFile.canRead()) {
versionProps.load(new FileInputStream(versionPropsFile))
}
def code = versionProps['VERSION_CODE'].toInteger()
def name= versionProps['VERSION_NAME']
flavorDimensions "environment"
productFlavors {
production {
versionCode code
versionName name
}
staging{
versionCode code
versionName name
}

Senior Software Engineer(Android). Open Source Contributor, Technical Writer, Email: Dani.amjad12@gmail.com check my website at https://danishamjad.com/

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store