Chapter 6Android Build System

WHAT'S IN THIS CHAPTER?

  • Android build system: Gradle
  • Using Gradle
  • Managing dependencies
  • Configuring Android Plugin for Gradle
  • Writing a Gradle plugin

Android Studio has introduced many changes to the Android development lifecycle that are limited not only to the IDE and tools but also to the build system. A Gradle-based build system was introduced with the initial release of Android Studio.

Prior to Android Studio, the Android ecosystem did not have one default build system. Some developers relied on Apache Ant scripts, whereas other developers preferred more sophisticated Maven builds. Another popular way to build Android apps uses mk files, which were widely used by developers using the Native Development Kit (NDK).

A common and yet simple approach followed by developers was to copy libraries (jar or aar files) into the libs folder and let Eclipse build tools to handle the build. However, this approach created problems when the project was integrated with source control systems. Although Maven addressed most of the dependency and automated test/build issues, it introduced another layer of complexity and performance problems.

In this chapter, you learn how to use Gradle effectively to control builds, manage dependencies and, even better, how to add custom tasks by writing your own plugins.

USING GRADLE

The Gradle build system was first released in 2007. Unlike Maven, which relies on XML, Gradle uses a Groovy-based domain-specific language for ...

Get Expert Android Studio now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.