Android-Developer-Tools

Work with build variants

To define two product flavors, edit the build file for the app module to add the following configuration:

...
android {
    ...
    defaultConfig { ... }
    signingConfigs { ... }
    buildTypes { ... }
    productFlavors {
        demo {
            applicationId "com.buildsystemexample.app.demo"
            versionName "1.0-demo"
        }
        full {
            applicationId "com.buildsystemexample.app.full"
            versionName "1.0-full"
        }
    }
}
...

The product flavor definitions support the same properties as the defaultConfig element. The base configuration for all flavors is specified in defaultConfig, and each flavor overrides any default values. The build file above uses the applicationId property to assign a different package name to each flavor: since each flavor definition creates a different app, they each need a distinct package name.

Note: To distribute your app using Multiple APK Support in Google Play, assign the same package name to all variants and give each variant a different versionCode. To distribute different variants of your app as separate apps in Google Play, assign a different package name to each variant.