Configure Build Variants in Android
Posted By : Prince Bhardwaj | 31-Jan-2018
Configure Build Variants
In this, we are going to discuss how we can create different versions of our application from a single project. We can create and configure build types in module level build.gradle. When we create a new module, Android Studio automatically creates the debug and release build types for us. The troubleshoot fabricate sort won't show up in manufacture setup record, we can design it with debuggable genuine. This will enable us to investigate the application safely on Android gadgets and arranges APK marking with a non specific troubleshoot keystore.
We can add debug build type to our configuration to add or change certain settings. The following specifies an application suffix for the debug build type and configure a staging build type that is initialized using settings.
android {
defaultConfig {
manifestPlaceholders = [hostName:"www.example.com"]
...
}
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
debug {
applicationIdSuffix ".debug"
debuggable true
}
staging {
initWith debug
manifestPlaceholders = [hostName:"internal.example.com"]
applicationIdSuffix ".debugStaging"
}
}
}
When we do any progressions to construct arrangement document, Android Studio expects us to synchronize the task with the new setup.
Configure Build Flavours
We can create product flavors similar to build types. To do this, we have to add them to productFlavours and configure the settings we want. The productFlavours supports same properties which defaultConfig have. This implies, we can give the base arrangement to all flavors in a defaultConfig square and we can likewise change any of these qualities.
Note: If we are using Android Plugin for grade 3.0.0 or higher, we must assign each flavor to the flavor dimension.
The following code sample creates "demo" and "full" product flavors which provide their own application suffix and versionName Suffix:
android { ... defaultConfig {...} buildTypes {...} productFlavors { demo { applicationIdSuffix ".demo" versionNameSuffix "-demo" } full { applicationIdSuffix ".full" versionNameSuffix "-full" } } }
Cookies are important to the proper functioning of a site. To improve your experience, we use cookies to remember log-in details and provide secure log-in, collect statistics to optimize site functionality, and deliver content tailored to your interests. Click Agree and Proceed to accept cookies and go directly to the site or click on View Cookie Settings to see detailed descriptions of the types of cookies and choose whether to accept certain cookies while on the site.
About Author
Prince Bhardwaj
Prince Bhardwaj is having Talent as Application Developer, he is an enthusiastic team player in Oodles Technologies.