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 was the victim of a MITM ('Martian in the middle') attack.
The preview of this section was whisked away by a shark-infested tornado.
The preview of this section is out seeking fame and fortune as the Dread Pirate Roberts.
The preview of this section was lost in the sofa cushions.
The preview of this section was eaten by a grue.
The preview of this section was lost due to a rupture in the space-time continuum.
The preview of this section was accidentally identified as an Android 'tasty treat' by the Cookie Monster.
The preview of this section is en route to Mars.
The preview of this section was fed to a gremlin, after midnight.
The preview of this section is unavailable right now, but if you leave your name and number at the sound of the tone, it might get back to you (BEEEEEEEEEEEEP!).