Skip to content
Book Cover of Extending Android Builds

Preface ​

Around 2013, I was deeply enamored with the exciting experiences offered by Android smartphones. Being eager to dive into Android development, witnessing the unveiling of Android Studio at Google IO felt like a game-changer to me. Without hesitation, I jumped on board with this new tool to kickstart my learning journey. I often teased that I'd write this book someday, feeling confident that mastering Gradle and Android Gradle Plugin (AGP) wasn't as daunting as it might seem, especially since I was an early adopter—considering my limited knowledge of Eclipse and ADT.

During 2016-2018, I was working in a fast-paced mobile foundation team. In a bustling team environment, ensuring developer productivity and streamlining CI/CD workflows were paramount. Consequently, I contributed numerous optimizations to our Android project, leveraging tools like annotation processors and Gradle plugins. At that time, I read extensively from Gradle and build related books and documents. Combining this with practical work experience, I noticed two critical challenges faced by Android developers diving into Gradle and AGP:

  1. Documentation Gap: Gradle's documentation lagged behind its rapid evolution. Learning resources were scarce, often geared towards Java or web development rather than Android specifics.
  2. Limited AGP Ecosystem: While its core aim was to support various new features in Android development, its outreach to third-party developers felt inadequate. The early Variant API offered minimal extension points, forcing developers to delve into AGP source code for deeper integration.

Believing millions of Android developers craved a structured learning resource, I decided to bridge this gap—challenges that can't be resolved solely by configuring AGP Extensions. My experience writing about Android infrastructure on my blog instilled confidence in tackling this challenge: to explain common extension methods within the Android build process through a book. Naturally, in 2018, I drafted the initial outline of this book and set out to design accompanying sample code.

However, the depth of content I envisioned soon surpassed my initial expectations, requiring additional learning and exploration. From 2019 onwards, I devoted more time to learning and maintaining open-source projects. Also, I actively shared insights on Android building and Kotlin compilation at various conferences (Android Worldwide, Google Devfest, Google IO Extended) from 2021 onwards. Engaging with the community not only inspired me to extend the scope of the book but also fueled my drive to keep the book's content abreast of the latest Gradle and AGP versions.

By 2023, the manuscript was eventually complete. Throughout five years of continuous revisions and updates, I've been fortunate to identify certain cores that remained unchanged within the realm of Android build technology. For instance, the introduction of Lazy Properties has been pivotal in the design of the new AGP Artifact API for the next few years. These points have been added to the architecture design, background knowledge, and deep technical details of various sections. As a saying goes, give someone a fish and you feed them for a day; teach someone to fish and you feed them for a lifetime. I hope this not only ensures the enduring value of this book but also caters to readers aiming to grasp the fundamentals of build technology.