PERFORMANCEFeb 17, 2026 // 11 min read // Written by Founders

SPEEDING UP ANDROID GRADLE COMPILATIONS: CACHING, DAEMONS, AND PARALLEL RUNS

Gradle is a powerful compilation engine, but Android builds are notoriously sluggish when Gradle is poorly configured. A mid-sized React Native app with 200+ dependencies can take 8+ minutes to compile on stock settings. With the optimizations below, we've consistently reduced that to under 90 seconds on dedicated M4 hardware.

The bottlenecks fall into four categories: JVM startup, dependency resolution, task execution, and I/O throughput. Each requires targeted tuning.

Configure gradle.properties for Maximum Throughput

Add these flags to your project's gradle.properties file to enable parallel compilation, build daemons, configuration caching, and optimized JVM memory:

# Enable gradle daemon (persistent warm JVM process)
org.gradle.daemon=true

# Compile independent modules simultaneously
org.gradle.parallel=true

# Cache task outputs for reuse across builds
org.gradle.caching=true

# Cache the configuration phase itself (saves 3-8s per build)
org.gradle.configuration-cache=true

# Optimize JVM memory for large projects
org.gradle.jvmargs=-Xmx4g -XX:+UseParallelGC -XX:MaxMetaspaceSize=1g -XX:+HeapDumpOnOutOfMemoryError

# Enable file system watching (detects changes without full scan)
org.gradle.vfs.watch=true

# Use non-transitive R classes to reduce resource processing
android.nonTransitiveRClass=true

What Each Flag Does

PropertyDefaultOptimizedImpact
gradle.daemontruetrueKeeps warm JVM between builds (saves 5-15s cold start)
gradle.parallelfalsetrueMulti-module projects build 2-4x faster
gradle.cachingfalsetrueSkips unchanged tasks entirely (40-70% time savings)
configuration-cachefalsetrueCaches build script evaluation (3-8s savings)
vfs.watchfalsetrueIncremental builds skip full filesystem scans
nonTransitiveRClassfalsetrueReduces resource processing by 30-50% in multi-module projects

Profiling Gradle Compilation Bottlenecks

Before optimizing, measure what's slow. Run a profile trace to generate a detailed HTML report:

# Generate build profile report
./gradlew assembleRelease --profile --no-daemon

# View the report
open build/reports/profile/profile-*.html

The report breaks down timing into configuration, dependency resolution, task execution, and artifact transforms. Focus on the slowest tasks first.

Using Gradle Build Scans

For deeper analysis, enable Gradle Enterprise build scans (free for open-source projects):

# Run with build scan
./gradlew assembleRelease --scan

# The output includes a URL to the interactive build scan dashboard

Build scans provide timeline visualizations, critical path analysis, and dependency insight reports that identify which modules and tasks dominate your build time.

Implementing Cache Warming in CI/CD

Make sure your pipelines persist and restore these directories between runs:

# Cache these directories between CI runs
# ~/.gradle/caches — downloaded dependencies and transform caches
# ~/.gradle/wrapper — Gradle distribution binaries
# ~/.android/build-cache — Android-specific compilation caches
# .gradle/ (project-level) — local build cache and file hashes

# Example: restore caches before build
tar -xzf gradle-cache.tar.gz -C $HOME/.gradle/ 2>/dev/null || true

# Build the project
./gradlew assembleRelease

# Save caches after build
tar -czf gradle-cache.tar.gz -C $HOME/.gradle caches wrapper

Restoring Gradle caches reduces dependency resolution from minutes to under 3 seconds. Our M4 Apple Silicon runners come pre-warmed with common Android SDK caches, achieving sub-minute compilation for most projects.

Optimization Results

Optimization StageBuild DurationImprovement
Stock Settings (Cold Build)8m 24sBaseline
+ Daemon + Parallel4m 12s50% faster
+ Build Caching2m 08s75% faster
+ Configuration Cache + VFS1m 34s81% faster
+ M4 Bare-Metal Hardware0m 48s90% faster

For tips on managing Android bundle sizes after compilation, read Shrinking React Native IPAs & APKs.

References & Citations

← BACK TO ARTICLES