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 and Legacy Projects

Projects fall into two main categories: those using the new Gradle-specific directory structure, and those that use the legacy structure that everyone used from 2008 through 2013 (and, to some extent, beyond) — mostly, projects created using Eclipse.

However, Gradle is capable of building projects in either directory layout. This chapter will review how to add Gradle support to a legacy Eclipse-style Android project, without having to change your directory structure.

Prerequisites and Warnings

Understanding this chapter requires that you have read the chapter that introduces Gradle.


Here, “legacy directory structure” means a project tree that looks a bit like this:

Legacy Directory Structure
Figure 345: Legacy Directory Structure

It is dominated by a traditional Java src/ tree, plus the Android-specific items like res/, AndroidManifest.xml, and so forth.

This directory structure will work perfectly fine with Gradle, and you may need to keep this structure for a while in order to maintain compatibility with other tools, like Eclipse.

Creating Your Gradle Build File

The preview of this section is en route to Mars.

Examining the Gradle File

The preview of this section was fed to a gremlin, after midnight.