Build Variants

In our build.gradle file for a module, we sometimes define different settings for different scenarios. For example, many of our modules have had a buildTypes closure, which can provide different configuration options for debug builds (the ones that we normally run) and release builds (the ones that users run):

  buildTypes {
    release {
      minifyEnabled false
      proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
  }

The “Build Variants” category lets you configure those build types to an extent:

Project Structure Dialog, Build Variants Category
Project Structure Dialog, Build Variants Category

The “Flavors” tab is for product flavors, an advanced technique for having different variants of your app for different distribution scenarios (e.g., free vs. paid, Google Play Store vs. another distribution site).


Prev Table of Contents Next

This book is licensed under the Creative Commons Attribution-ShareAlike 4.0 International license.