# Declarative, Agent-Ready Android Builds with Lightbuild

> Master Google's declarative build system for Android. Learn how Lightbuild replaces imperative Gradle scripts with schema-validated YAML, pre-resolved lockfiles, and deterministic AI agent workflows in ICanHazStream.

- **Author**: Kartik Arora
- **Live Presentation**: https://presentations.kartikarora.me/lightbuild/
- **Topics**: Android, Lightbuild, Gradle, AI, Tooling

---

## Slide 1: Declarative, Agent-Ready Android Builds with Lightbuild

### Declarative, Agent-ReadyAndroid Builds with Lightbuild

Kartik Arora

Lead Engineer @

GDE Android

kartikarora.me

---

## Slide 2: Follow Along

### Follow Along

Presentation Slides

Hands-on Codelab

Repository: github.com/kartikarora/ICanHazStream

---

## Slide 3: Overview

### Overview

build

### 1. Build Script Trade-offs

How imperative execution impacts IDE sync times and automated coding agents.

data_object

### 2. Lightbuild Architecture

Schema-validated YAML, app shell structure, and resolved.deps lockfiles.

account_tree

### 3. Migration: ICanHazStream

Converting an 8-module Compose app and verifying automated module scaffolding.

analytics

### 4. Status & Trade-offs

Sync benchmarks, agent edit reliability, and current evaluation scope.

---

## Slide 4: Part 1: The Imperative Configuration Model

### Part 1: The Imperative Configuration Model

Analyzing configuration-time execution costs in multi-module Android codebases.

---

## Slide 5: Executable Build Scripts

### Executable Build Scripts

### Gradle Configuration Phase Overhead

### Configuration-Time Execution

- Arbitrary JVM Code: Evaluates lambdas, plugins, and custom logic before any task runs.

- Graph Recalculation: IDE sync requires running scripts across all modules to resolve dependencies.

- Dynamic Version Resolution: Remote repository lookups on initial open or branch change.

### Operational Impact

- Sync Latency: Cold syncs take 30 to 60+ seconds in multi-module repositories.

- Memory Footprint: Gradle daemons consume significant memory during configuration.

- Maintenance: Composite builds and convention plugins require ongoing upkeep.

---

## Slide 6: Automated Edits in Imperative Scripts

### Automated Edits in Imperative Scripts

Common failure modes when AI coding agents modify Kotlin DSL build files:

error_outline

### Syntax & Scoping Errors

Mismatched braces, misplaced plugins {} blocks, or version catalog syntax discrepancies fail configuration.

call_split

### Side-Effect Dependency

Agents cannot easily evaluate conditional logic or plugin inheritance without running the script.

code

### Token Overhead

Passing multi-file Gradle DSL scripts and classpaths consumes significant prompt token budget.

---

## Slide 7: Part 2: Lightbuild Architecture

### Part 2: Lightbuild Architecture

Google's declarative configuration layer for Android projects.

---

## Slide 8: Transpilation Model

### Transpilation Model

Lightbuild acts as a declarative frontend that compiles to Gradle and AGP instructions:

---

## Slide 9: Root Manifest: project.lightbuild.yaml

### Root Manifest: project.lightbuild.yaml

Combines repository definitions, module lists, and compiler toolchains into a single file:

```

project:

name: ICanHazStream

modules:

- app

- app-core

- core/model

- core/data

- core/ui

- feature/explore

- feature/details

repositories:

- google

- mavenCentral

lightbuild:

version: 0.0.30

build:

java:

version: 17

kotlin:

version: 2.4.20

jvmTarget: "17"

```

---

## Slide 10: Module Configuration: App Shell vs. Library

### Module Configuration: App Shell vs. Library

Application modules are thin assembly shells; actual code lives in app-core library:

### app/lightbuild.yaml (Thin Shell)

```

module:

type: application

android:

namespace: me.kartikarora.icanhazstream

applicationId: me.kartikarora.icanhazstream

compileSdk: 36

minSdk: 24

targetSdk: 36

dependencies:

- module: app-core

```

### app-core/lightbuild.yaml (Library)

```

module:

type: library

android:

namespace: me.kartikarora.icanhazstream

compileSdk: 36

minSdk: 24

dependencies:

- module: core/ui

- module: core/data

- module: feature/explore

```

Key Architecture Rule: Application modules in Lightbuild are empty shells without visibility into source code in app/src. All app entry points (MainActivity) must live in a library like app-core.

---

## Slide 11: Dependency Locking: resolved.deps

### Dependency Locking: resolved.deps

Deterministic dependency tracking for Android builds:

lock

### Pinned Transitive Tree

Stores exact versions for all direct and transitive dependencies per module.

speed

### Offline Sync

Reads pinned dependencies from disk during IDE sync without querying remote repositories.

terminal

### Managed by CLI

Regenerated by running lightbuild resolve. Committed to version control.

---

## Slide 12: Part 3: Migration &amp; Agent Workflow

### Part 3: Migration & Agent Workflow

Migrating ICanHazStream and executing automated module scaffolding.

---

## Slide 13: Sample Application Architecture

### Sample Application Architecture

### ICanHazStream: 8-Module Jetpack Compose App

---

## Slide 14: Agent Workflow Loop

### Agent Workflow Loop

Interaction pattern for AI coding tools in Lightbuild repositories:

---

## Slide 15: Live Walkthrough: Scaffolding a Module

### Live Walkthrough: Scaffolding a Module

### Automating :feature:reviews Addition

terminal

### Automated Scaffolding Steps

Prompt: "Add feature/reviews module with Compose M3 dependencies and wire it to app."

- 1. Agent updates project.lightbuild.yaml and creates feature/reviews/lightbuild.yaml

- 2. Run lightbuild resolve to update resolved.deps

- 3. Run lightbuild build to compile target artifacts

---

## Slide 16: Part 4: Metrics &amp; Scope

### Part 4: Metrics & Scope

Synchronization timings, agent reliability metrics, and evaluation scope.

---

## Slide 17: Performance Comparison

### Performance Comparison

### ~1.1s

### IDE Project Sync

Static schema parsing versus 40+ seconds cold sync with composite convention plugins.

### 98%

### Agent Edit Success

Deterministic data mutation prevents common Kotlin DSL syntax and scoping failures.

### Zero

### Configuration-Time JVM Logic

Eliminates JVM code execution during project structure discovery.

---

## Slide 18: Adoption Considerations

### Adoption Considerations

### Suitable Use Cases

- New Applications: Greenfield projects and modern Compose codebases.

- Workshops & Codelabs: Fast, reproducible project onboarding.

- Agentic Workflows: Automated feature scaffolding and dependency management.

- Prototypes: Quick validation of modular layouts.

### Keep Kotlin DSL

- Custom Build Logic: Projects with bespoke Gradle tasks or bytecode manipulation.

- Complex Release Pipelines: Custom signing or publishing plugins.

- Large Production Monorepos: Codebases dependent on enterprise Gradle infrastructure.

---

## Slide 19: References &amp; Resources

### References & Resources

Primary Sources:

- Android Dev Summit Session · YouTube Recording

- Google Android Lightbuild Guide

- github.com/kartikarora/ICanHazStream (branch: main &rarr; lightbuild)

- Hands-on Codelab

menu_book Open Codelab

---

## Slide 20: FIN.

### FIN.

Thank you.

Kartik Arora

kartikarora.me

---

