How to build different flavors of an Android project


It might happen that you will have multiple flavors of APKs. Usually gradle makes it very easy to select the flavor of the project by putting the flavor name to the specified place in the gradle task’s name.

Here is a simple and easy description of the build types(debug/release) and also there we have a note about build variants:

The “Debug” part in the above task names is just a camel-case version of the build variants name, so it can be replaced with whichever build variant you want to assemble or install. For example, if you have a “demo” product flavor, then you can build the debug version with the assembleDemoDebug task.

Also the configuration of flavors made really quick by gradle:

android {
    defaultConfig {...}
    buildTypes {...}
    productFlavors {
        demo {
            applicationIdSuffix ".demo"
            versionNameSuffix "-demo"
        full {
            applicationIdSuffix ".full"
            versionNameSuffix "-full"

After you are sure about the flavor you will need, the only thing you need to change on Bitrise will be the gradle-runner step’s gradle task input.

Usually, if you need more than one of your variants in a single build, you can do two things:

  1. Use one gradle-runner step, with a simple assembleDebug (without any flavor, just the type is enough), so it will generate all the flavors, or just list the tasks separated by a space for example: assembleFlavor1Debug assembleFlavor2Debug
  2. Use multiple gradle-runner step, so you can define the exact flavors you need, for example: assembleFlavor1Debug in the first gradle-runner, and assembleFlavor2Debug in the second, the point of using separated gradle-runner step is that this way the env $BITRISE_APK_PATH after the gradle-runner step will contain the only flavor just built. For example: /path/to/my/flavor1-debug.apk and /path/to/my/flavor2-debug.apk So this way Sign APK and Google Play Deploy steps can automaticall pick up the APK to work with. :wink:

Feel free to ask any questions! :rocket::slightly_smiling_face:


How do generate Android APKs by build variants?

Cool. What would you put in the “package name” in the deploy to google step if you use something like assembleRelase in your gradle runner step which creates a bunch of flavours with different package names?

1 Like


Hi @Jyllands-Posten,

The “package name” input field specifies the app ID in Google Play, it is not strictly connected to your build output artifacts.

In case of multiple build variants, you would specify the actual APK tp upload in the “APK path” input.

Did that answer your question? :slight_smile:



I guess it did. I ended up doing a fork of the google deploy step which uses aapt to resolve the package names of the apk files, then uploads them one by one…



Hi, how do we change build version numbers for multiple flavors?



@anupamchugh The Change version number step works by updating versionCode and versionName in your build.gradle config file, so building any flavor after this step will use the updated version number.