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.
A previous chapter showed how you can use Gradle, and the Android Plugin for Gradle, to do command-line builds of projects that can also work with Eclipse, IntelliJ IDEA, Ant, etc.
However, while the legacy project directory structure works, it does not let you leverage the full power of the Android Plugin for Gradle. To take advantage of the build flexibility of the new build system, you will need to organize your source, resources, assets, and related files somewhat differently.
This chapter will outline this “new project structure” and show you how the Android Plugin for Gradles’s concepts of build types and product flavors will make it easier for you to have multiple different forms of output from a single, albeit reorganized, project tree. This project structure is native to Android Studio, so Android Studio projects are already set up to be able to support these sorts of advanced capabilities.
Understanding this chapter requires that you have read the chapters that introduce Gradle and cover basic Gradle/Android integration, in the context of covering the use of Gradle with the legacy 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 Plugin for Gradle and Gradle itself, makes all of this possible… albeit with a bit of a learning curve.
The preview of this section is [REDACTED].
The preview of this section took that left turn at Albuquerque.
The preview of this section apparently resembled a Pokémon.
The preview of this section was stepped on by Godzilla.
The preview of this section left for Hollywood to appear in a reality TV show.
The preview of this section is being chased by zombies.
The preview of this section is off trying to sweet-talk the Khaleesi into providing us with a dragon.
The preview of this section is sleeping in.
The preview of this section is presently indisposed.
The preview of this section is out seeking fame and fortune as the Dread Pirate Roberts.