Android Product Flavors

Updated 29 July 2020


Android product flavors are variants of your app. It is very useful when you want to create multiple versions of your app. This means you can generate different versions or variants of your app using a single codebase.
Product flavors are a powerful feature of the Gradle plugin from Android Studio to create customized versions of products. They form part of what we call Build Variants.

Build Variants Build variants are the result of Gradle using a specific set of rules to combine settings, code, and resources configured in your build types and product flavors.

Build Type applies different build and packaging settings. An example of build types are “Debug” and “Release”.

When to use Product Flavors

Pros and Cons



Product Flavors Creation

For creating product flavors in android, we just need to add productFlavors block inside the android block in app-level build.gradle file.

You can now create source sets folders app/src/admin/ and app/src/customer/ parallel to app/src/main/. The common classes and resources can stay in app/src/main while the flavor dependent code can go in the respective folders.

Resource Files Creation

Switch to project view in the left panel and then expand all directories until src and then right-click on src then navigate to

new > Folder > Res Folder

Then you’ll see a popup with two fields

Target Source set is nothing but the source code directories for selected flavor.

The New folder location is the location where the file will be created.

Similarly, we can create a directory for all flavored build types if necessary.


Java Files Creation

Creating a java directory for each flavor is similar to resource directories creation. The only difference is that we select a java folder instead of the Res folder.


Build Variant

Build variant combines your build types and product flavors. Sync your project after you update your build.gradle, select Build > Select Build Variant in the menu bar, and you will see the different Build Variants auto-generated when you added the Product flavors.

. . .

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