Android Studio Tips and Tricks advocates that build variants are a feature not yet fully implemented. However you can manage that with Gradle itself, as documented into the Gradle Plugin User Guide. You basically define variants and get an autogenerate BuildConfig.java
file.
For instance you could define two flavor, release and debug like this:
release {
buildConfig "public static final String RELEASE = true;"
}
debug {
buildConfig "public static final String RELEASE = false;"
}
inside your android/buildVariants section into build.gradle
and this will include this boolean variable in the automatically generated BuildConfig.java
for use in your application to differ in behaviour.
See also Using Build Flavors - Structuring source folders and build.gradle correctly and this blog post about build variants.