Cash Android Moves to Metro
Article Summary
Egor Andreevich just shipped a DI framework migration across 1,500 modules serving tens of millions of users. The build speed improvements? Nearly 60% faster incremental builds.
Cash App's Android team migrated from Dagger/Anvil to Metro, a modern Kotlin-first dependency injection framework. The challenge: doing it safely across a massive production codebase while maintaining the ability to build with both frameworks during the transition.
Key Takeaways
- Incremental builds improved 59%, clean builds 16.7% faster after migration
- Built dual-mode system to compile with both Dagger and Metro simultaneously
- Eliminated kapt entirely, now running DI codegen during Kotlin compilation
- Metro's stricter validation caught nullability bugs Dagger missed
- Unlocked K2 compiler adoption blocked by Anvil compatibility
Cash Android achieved 60% faster incremental builds and eliminated kapt by migrating to Metro while maintaining production stability through a dual-framework build system.
About This Article
Cash Android's 1,500-module codebase used Dagger's Java-based annotation processor, which required kapt. This made the build pipeline complex and blocked the adoption of Kotlin 2.0's K2 compiler, even though it was stable and offered better performance.
Egor Andreevich's team used Metro's interop functionality to build the codebase in both Dagger/Anvil and Metro modes at the same time. A Gradle property controlled which mode ran, letting them validate both approaches in parallel across CI shards before committing to the full migration.
Removing kapt and running dependency injection codegen during Kotlin compilation gave Cash Android 58.5% faster incremental builds for non-ABI changes and 16.7% faster clean builds. The team could also adopt the K2 compiler.