Month: January 2018

We may need to create different versions of an APK file based on an application type (free or paid application), the server environment type (QA, UAT) & etc.

To reduce the convolution of making different versions of an APK file, Android Studio uses Gradle, a build toolkit, to automate and manage the build process. It allows us to define flexible custom build configurations. Each build configuration can define its own set of code and resources while reusing parts common to all the application versions. It enables us to have multiple similar versions of an app within a single code base like different colors, dependencies & etc.

Step 1: Create a New Project with Android Studio.

Name the Application to {anything of your choice} & then click Next. I have currently named it buildvariant.

Step 2: Configure your app

Select the API Version (I took it as 15) as per your Target Audience. Under Phone and Tablet select the API and the click Next.

Select Empty Activity and then click Next.

Keep the Activity name as MainActivity (or any name of your choice) and click Finish.

MainActivity is the Default name

Step 3: Project Settings

Under the heading Gradle Scripts browse for build.gradle(Module:app)

Append the build.gradle file with the following under the buildTypes DSL: