The following is the first few sections of a chapter from The Busy Coder's Guide to Android Development, plus headings for the remaining major sections, to give you an idea about the content of the chapter.


Gradle Build Variants

You may think that the directory structure and files involved in an Android Studio project is a bit complicated. In truth, what you have seen so far is actually fairly simple, when you start to consider the real world of product development. Simple apps can get by with simple structures like we have seen so far, but:

In this chapter, we will explore the concept of “build variants” in Gradle and Android Studio and how you can take advantage of them for your projects.

Prerequisites

Understanding this chapter requires that you have read the chapters the core chapters of the book.

Objectives of the Project Structure

In the beginning, Android apps tended to be pretty simple, as we only had a handful of devices, a smattering of users, one primary distribution channel (the then-Android Market) and few major investors in the Android ecosystem.

Times have changed.

Now, Android apps for public consumption can be terribly complex, let alone apps for internal enterprise use (which seem to be complex as a side effect of being developed by an enterprise). We have multiple distribution channels, such as the Amazon AppStore for Android and Yandex.Store. We have a billion devices and nearly a billion users. Brands large and small are flocking to Android, bringing with them their own challenges.

The new build system is designed to simplify creating complex Android applications, while, ideally, not making simple Android applications a lot harder. It is designed for scenarios like:

The new project structure, coupled with the Android Gradle Plugin and Gradle itself, makes all of this possible… albeit with a bit of a learning curve.

Terminology

The preview of this section was eaten by a grue.

Configuring the Stock Build Types

The preview of this section was stepped on by Godzilla.

Adding Build Types

The preview of this section left for Hollywood to appear in a reality TV show.

Adding Product Flavors and Getting Build Variants

The preview of this section left for Hollywood to appear in a reality TV show.

Doing the Splits

The preview of this section is in an invisible, microscopic font.

Gradle and Android Studio

The preview of this section is off trying to sweet-talk the Khaleesi into providing us with a dragon.