
With the initial project created, the next step is to configure the module level adle file to add the two build flavor configurations.

Adding the Build Flavors to the Module Build File Continue to proceed through the screens, requesting the creation of a blank activity named BuildExampleActivity with the remaining fields set to the default values. On the form factors screen, enable the Phone and Tablet option and set the minimum SDK setting to API 19: Android 4.4 (KitKat). The project will then be further extended to provide an example of how each flavor might make use of different source code bases in order to provide differing application behavior.Ĭreating the Build Variant Example ProjectĬreate a new project in Android Studio, entering BuildExample into the Application name field and as the Company Domain setting before clicking on the Next button. Initially the two flavors will be configured such that they differ only visually in terms of the resources that are used for each target such as layouts and string values. The build flavor, on the other hand, typically defines what is built (such as which resource and source code files are to be included in the build) for each variant of the module. In general, a build type defines how a module is built (for example whether or not ProGuard is run, how the resulting application package is signed and whether debug symbols are to be included). This raises the question as to the difference between a build type and a build flavor. The end result, therefore, will be four build variant options available for selection within Android Studio:

The build environment will be configured such that each flavor can be built using either a release or debug build type. Hesitate to drop a comment below or tweet at me.The goal of this chapter is to use the build variants feature of Android Studio to create a project which can be built in two flavors designed to target phone and tablet devices respectively. If you have any comments/suggestions or corrections, I’d love to hear them. I also use this technique to manage minSdkVersion, targetSdkVersion, compileSdkVersion and buildToolsVersion in my projects.Ĭheck out this gist for a fuller example of how I do this.
