Product flavors are defined in the build.gradle
file inside the android { ... }
block as seen below.
...
android {
...
productFlavors {
free {
applicationId "com.example.app.free"
versionName "1.0-free"
}
paid {
applicationId "com.example.app.paid"
versionName "1.0-paid"
}
}
}
By doing this, we now have two additional product flavors: free
and paid
. Each can have its own specific configuration and attributes. For example, both of our new flavors has a separate applicationId
and versionName
than our existing main
flavor (available by default, so not shown here).