Android Build Variant

Updated 24 October 2020


Build variant

Build variant is used to create different version of application in single project. Each Build variant creates different versions of our app. Like, you wanna make any music application with two version, one is free and other one is paid.

Build variant is result of build type and product flavor.

Build type : debug, release
Product Flavor : first, second

Build Variant : firstDebug, firstRelease, secondDebug, secondRelease

Gradle creates every possible combination of build type and product flavor as build variant by default.

Build Type

Build type defines in build.gradle files. Android Studio provides two type of build type.
1. debug
2. release
When we create any project in Android Studio, it automitacally creates build type for us. The debug build type doesn’t apprear in build file, Android Studio configures it with debuggable true. You can add debug block in build.gradle file and configure its setting.
Debug version is used for testing purpose. If you wanna create upload app on play store, you need to create releasable version.
Android Studio configure build type with debuggable true. If you wanna upload release version on play store, so you need to set it false in build.gradle in release block.

Product Flavor

For product flavor, we add block in build.gradle same as build type. The product flavors support the same properties as defaultConfig—this is because defaultConfig actually belongs to the ProductFlavor class. You can change any property of defaultConfig in product flavor block and set different for all product flavor. For example, there are two applications for cab booking, one for driver and one for customer. Both app code is written in one project. So, you need to define two product flavor and set different applicationid.

Product flavors must belongs to product dimension. It is basically group of product flavors. You must assign all flavors to a flavor dimension; otherwise, you will get the build error :  ERROR: All flavors must now belong to a named flavor dimension.

Product Dimension

Add following line in builder gradle :

Gradle File after adding product flavour

Suppose, you have different Home page of application for guest user and paid user. So, according to product flavour, home page will be called.

Filter variant

Gradle creates every possible combination of build type and product flavor as build variant by default. If you wanna remove any build variant, you can filter it.


Hope, this blog is helpful for you.

Also, check following link : Android Build

. . .

Leave a Comment

Your email address will not be published. Required fields are marked*

Be the first to comment.

Start a Project

    Message Sent!

    If you have more details or questions, you can reply to the received confirmation email.

    Back to Home