We’ll teach you how to make Android product flavors programmatically using Android Studio and Gradle build tool. You can use this technique to create duplicate Android apps or Android app clones. This is an advanced tutorial.
We often have to launch similar apps for different markets, countries or niches. Same Android mobile game can become different over holiday seasons to accommodate product placement or a social event. Similarly, due to copy rights we may have to make slight changes to an app before launching it in another country.
In such a case, there may be a strong inclination among the mobile app developer to create multiple versions from scratch or be willing to charge twice or thrice the original cost from the client. With Android product flavors, this cost can be saved and further invested in bringing more advanced app features or new concepts to market.
Android product flavors also known as Android build types or Android build variants are the native Android app development way to implement different versions of the same application with minor changes provided by Gradle and Android Studio together. Here is the official Android documentation for configuration of Android product flavors.
Android product flavors are for different types of the same application with just configuration changes like staging and production environment.
By default there are two build types available in android studio project i.e.
Here in build types you can change the configuration like link for staging and production environment on server.
If you need to differentiate between different configurations of an Android application, you need Android build types and if you need to release a new Android application with change features you need Android product flavors.
In latter part of the article, we will describe when and why you need product flavors. We will also demonstrate how different flavors of an application are implemented using Gradle and Android Studio.
As a mobile application developer, you can have a scenario where you would like to release a new application from your previous project with some minor changes like app icon, theme, name or anything else. For this purpose, we have two approaches
Option 1 looks simple but it can turn into a major maintenance headache.
Option 2 looks tricky and difficult in the start but it is very easy to manage and maintain afterwards.
Here comes the concept of product flavors.
Let’s say we have an application with three different flavors* i.e.
*The names of flavors could be anything might be (f1, f2, f3) or (flavor1, flavor2, flavor3)
All these flavors have same basic functionality but have different
Create an application with basic functionality.
Define build variants in Gradle like shown below.
And sync the Gradle.
After that in project structure view create three directories under app/src and name them exactly same as product flavors in Gradle
Now create sub directories with same hierarchy as in main folder to add new layouts, drawable and values for different flavors.
Now you have three different flavors of same application
To change the build variant, Android Studio uses: select Build > Select Build Variant in the menu bar (or click Build Variants in the windows bar), and then select a build variant from the drop-down menu.
Now change build variant from drop down menu and run application you have three different versions of same application (Screenshots attached).
buildTypes {
debug {
}
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard rules.pro'
}
}
productFlavors {
mango {
applicationId "com.therightsw.mango"
versionCode 1
versionName "1.0"
}
blueberry {
applicationId "com.therightsw.blueberry"
versionCode 1
versionName "1.0"
}
orange {
applicationId "com.therightsw.orange"
versionCode 1
versionName "1.0"
}
}
By following this tutorial, we are hopeful that you have understood basics of using Android product flavors/build variants. Send an email below if you need help in your app to create product flavors. You can also hire Android developers with us.
You do not have to write each Android mobile application from scratch and pay multiple times if you want to launch similar concepts in games or business apps with similar concepts and look-n-feel. Android product flavors will help you save development time and cost.
Link to github repository for the sample code.
Our support staff is available 24/7 to take support calls and messages from clients.
We involve client in all stages of software development to deliver satisfaction and peace of mind.
We hire developers that are technically strong and discuss the project thoroughly before starting.
If you are not happy with the quality of work or we fail to achieve final technical goal, we’ll not take your money.
We have worked with some clients for over 7 years. Our commitment and dedication is a matter of pride for us.
We care about your investment. We will tell it straight if you are making a bad decision.
NDA implied. No spam. Privacy guaranteed.
Best web, app, eCommerce and custom software development company. We provide services to more than 100 clients world-wide.
Contact The Right Software today to discuss the your next big idea.