Skip to content
Book Cover of Extending Android Builds

Extending Android Builds

Pragmatic Gradle and AGP Skills with Kotlin

Extending Android Builds (EAB) goes beyond Gradle configuration. It focuses on Gradle Plugin development that cooperates with AGP (Android Gradle Plugin) and related build tools such as AAPT2 (Android Asset Packaging Tool), KSP (Kotlin Symbol Processing) and bytecode manipulators with over 500+ pages. The primary language used in EAB is Kotlin.

Major technical topics including Gradle, Android Gradle Plugin, Kotlin Symbol Processors and JVM Bytecode.

With the help of multiple hands-on demos and case studies, you will learn how to craft Gradle plugins and tasks, how to integrate with the AGP APIs, and best practices for architecting, testing, and debugging Android builds. EAB explains not only "what" and "how", but also "why"—the art behind Gradle and AGP designs.

The art behind Gradle and AGP designs.

AGP's evolution in last 5 years

Gradle Lifecycle

Plugin Classification

Covering Gradle with Android Builds in Depth with Kotlin

Utilizing the AAPT2, KSP and Bytecode Manipulatros with Multiple Case Studies

Ranking #1 on Amazon Hot New Releases* (Category: Java, First Three Days)

  • Utilize the Kotlin language for both Gradle scripts and plugins.
  • Author Gradle plugins/tasks with confidence while effectively interacting with AGP APIs and Gradle raw APIs.
  • Monitor and modify various aspects of the Android build process, including resource files, source code, JVM bytecode, and even their combinations using AAPT2, Kotlin Symbol Processing (KSP), and multiple bytecode modifiers.
  • Ensure that the plugin is both robust and low-cost to maintain, following the simple test pyramid.
  • Adhere to the latest best practices in App architecture that align with many Gradle golden rules and offer extensibility for developers.
  • Reduce the build time of the Android application and enhance the efficiency of their existing CI/CD workflows.
  • Chapter 1, Concepts and Little Handmade: Provides insight into Gradle and Android Gradle Plugin basics, alongside manual Android app creation.
  • Chapter 2, Quick Start: Offers hands-on experience in structuring Gradle projects, understanding lifecycle, plugins, tasks, and creating a basic Gradle plugin for Slack notifications.
  • Chapter 3, The Key of Extending Android Builds: Focuses on mastering Android Gradle Plugin's Variant and Artifact APIs for efficient and customizable builds.
  • Chapter 4, Diving into the Gradle Raw APIs: Explores advanced Gradle raw API features like lifecycle hooks, lazy properties, task orchestration, and caching mechanisms.
  • Chapter 5, Extension of Android Resources Build: Covers manipulation of Android resources through AGP Extensions, with insights into AAPT2 internals for optimized builds.
  • Chapter 6, Extension of Source Code Build: Discusses manipulating source code through AGP Extensions and understanding Kotlin Symbol Processing (KSP) for code generation.
  • Chapter 7, Extension of the JVM Bytecode Build: Explores JVM bytecode manipulation using AGP APIs and tools, including Aspect-oriented Programming (AOP) at the bytecode level.
  • Chapter 8, Improving the Build Experience: Focuses on optimizing build experiences through analysis, performance tuning, and conditional plugin application.

To view a comprehensive TOC, please visit the books samples - TOC.

This book mainly targets intermediate-level (and above) Android developers, and all other Gradle users who have a need for Gradle skills sharpening, such as Java, React Native or Flutter developers. The knowledge prerequisites for this book fall into three categories:

  • Gradle: including a basic understanding of build scripts and dependency management.
  • Android build process: including basic configuration of Android Gradle Plugin and regular build commands.
  • Kotlin: basic syntax.

To make it specific, typical job roles for the primary readers are:
  • 1 year experience (or above) as a Mobile Developers / Android Developers.
  • 1 year experience (or above) as a Software Engineer and moved to a new role like Developer Experience (DX) Engineer / Developer Productivity Engineer / Release Engineer / Mobile Infrastructure Engineer / Tools & Foundation Engineer.
  • Full-stack Java (or other JVM languages) Engineer / Full-stack Engineer who would like to try mobile development as well.

Overall, this book not only aids in mastering theoretical knowledge but also enhances practical skills, laying the groundwork for advancing to the next career level and opening up diverse professional pathways.

Ultimately, for beginner-level developers can take KOGE (open-soourced and free) as a preparatory material.
El (Bingquan) Zhang is a seasoned software engineer residing in Singapore. With a wealth of experience in Android application infrastructure, he has spent years delving into technologies like Gradle, AGP, KSP, bytecode transformation, and modularity. His passion for Android development extends beyond coding—he finds immense joy in sharing insights through blog posts, podcasts, books, and conference presentations in both English and Mandarin. Since 2022, he has been recognized as a Google Developer Expert (GDE) for Android. During his downtime, he enjoys maintaining various open-source plugins and utilities that add value to the developer community. You can find him across platforms under the identity “2BAB”.

Copyright Since 2023 @2BAB