Metro is a new compile-time dependency injection framework for Kotlin, implemented as a compiler plugin. It draws inspiration from Dagger, Anvil, and kotlin-inject, aiming to unify their best features into a single cohesive solution. Key highlights include compile-time dependency graph validation, FIR/IR code generation, multiplatform support, IDE integration, and detailed error messages. Benchmarks on a real-world app (~35 modules) show build performance improvements of 25–56% depending on the scenario. Version 0.1.1 is available now, with features like optional dependencies, private providers, and top-level function injection. Future work includes nullable bindings and unused binding reporting.

3m read timeFrom zacsweers.dev
Post cover image
Table of contents
InstallationFeaturesBuild PerformanceFuture WorkFAQ
26 Impressions