Build Variants in Android
Overview
Build Variants is a tool of Android Studio which is used to manage different versions of your application. It can be found on the left hand side of Android Studio. If you want to define your custom build variant, you can define it in build.gradle (Module) file.
Steps to create Build Variant
- Add the following editable line of code in build.gradle (Module) file.
flavorDimensions "demo"
productFlavors {
production {
versionCode 12
versionName "1.0.0.12"
buildConfigField 'String', 'BUILDTYPE', '"PRODUCTION"'
buildConfigField 'String', 'SERVER_IP', '"201.201.201.201"'
}
uat {
versionCode 1
versionName "1.0.0.0"
buildConfigField 'String', 'BUILDTYPE', '"UAT"'
buildConfigField 'String', 'SERVER_IP', '"201.201.201.201"'
}
development {
versionCode 1
versionName "1.0.0.0"
buildConfigField 'String', 'BUILDTYPE', '"DEVELOPMENT"'
buildConfigField 'String', 'SERVER_IP', '"201.201.201.201"'
}
}
- You can add other buildConfigFields too in the respective sections of productFlavors
Do's and Dont's
- Do not forget to add flavourDimensions after adding productFlavours
flavorDimensions "demo"
- Hello World!!!
Comments
Post a Comment