---
title: "From Dagger to Metro"
description: "Vinted's Android team migrated a codebase of several hundred Gradle modules from Dagger, dagger.android and Anvil to Metro, a Kotlin compiler-plugin DI framework, mainly to escape Anvil's K1 lock-in and enable K2 and incremental compilation."
url: "https://swe.quest/articles/from-dagger-to-metro-e5fb22ba684a3a3d"
canonical: "https://vinted.engineering//2026/02/12/from-dagger-to-metro/"
source: "Vinted Engineering"
published: "2026-02-12"
difficulty: "medium"
kind: "Case study"
reading_minutes: 6
tags: ["mobile","jvm","refactoring","build-systems"]
---

# From Dagger to Metro

A post on [Vinted Engineering](https://swe.quest/sources/vinted.md), published 2026-02-12, 6 min read, Case study. Original: [https://vinted.engineering//2026/02/12/from-dagger-to-metro/](https://vinted.engineering//2026/02/12/from-dagger-to-metro/)

## Summary

Vinted's Android team migrated a codebase of several hundred Gradle modules from Dagger, dagger.android and Anvil to Metro, a Kotlin compiler-plugin DI framework, mainly to escape Anvil's K1 lock-in and enable K2 and incremental compilation. They did a big-bang migration without Metro's interop layer: scripted regex replacements for annotations, KSP-generated graph extensions to replace 100+ dagger.android fragment injectors, and updates to existing codegen. Pain points included compiler crashes and slow generated code on 0.x versions (mostly from member injection), stray javax.inject imports, and daily upstream merge conflicts. CI builds got 6–26% faster, with local builds improving further from incremental compilation.

Written by swe.quest, not by the author.

**Difficulty:** Medium: assumes a working developer; shows how it is built or done

## Topics

- [Mobile](https://swe.quest/tags/mobile.md) (Web & mobile)
- [Java & JVM](https://swe.quest/tags/jvm.md) (Languages)
- [Refactoring & migrations](https://swe.quest/tags/refactoring.md) (Engineering practices)
- [Build systems](https://swe.quest/tags/build-systems.md) (Engineering practices)

## Prerequisites

- Dagger dependency injection ([easy posts on Application security](https://swe.quest/tags/appsec.md?difficulty=easy))
- Kotlin compiler plugins ([easy posts on Java & JVM](https://swe.quest/tags/jvm.md?difficulty=easy))
- Gradle multi-module builds

## Keywords

Metro, Dagger, Anvil, Kotlin K2, KSP, Hilt, dagger.android

## Related posts

- [Extending Anvil for Fun and Profit](https://swe.quest/articles/extending-anvil-for-fun-and-profit-7f2a4cd8f637a17a.md): Slack Engineering · 2021-07-20 · Hard · 6 min read · Mobile, Java & JVM, Build systems, Compilers
  Slack's Android app replaced dagger-android activity injection with a custom Anvil code generator: annotating an activity with @InjectWith(scope) generates an AnvilInjector wrapping Dagger's intrinsic MembersInjector plus a @ContributesTo binding module that adds it to a scope-level multibinding map.
- [It’s a non-transitive R class world](https://swe.quest/articles/it-s-a-non-transitive-r-class-world-dc7be71b63e01554.md): Slack Engineering · 2023-02-01 · Medium · 5 min read · Mobile, Build systems, Refactoring & migrations, Static analysis, Developer productivity
  Slack migrated its 400+ module Android codebase to non-transitive R classes, where each module's R class contains only its own resources, yielding ~14% faster incremental builds after resource or layout changes and an ~8.5% (about 5.5MB) APK/DEX size reduction.
- [From zero to 10 million lines of Kotlin](https://swe.quest/articles/from-zero-to-10-million-lines-of-kotlin-e0f9a5140a87605f.md): Meta Engineering · 2022-10-24 · Medium · 13 min read · Java & JVM, Refactoring & migrations, Mobile, Developer tools
  Meta has converted its Android codebase to over 10 million lines of Kotlin by wrapping JetBrains' J2K converter in an automated pipeline called Kotlinator.
- [Enabling Kotlin incremental compilation on Buck2](https://swe.quest/articles/enabling-kotlin-incremental-compilation-on-buck2-bd5307852c0570ff.md): Meta Engineering · 2025-08-26 · Medium · 10 min read · Build systems, Java & JVM, Compilers, Developer productivity, Mobile
  Meta integrated the Kotlin incremental compiler into Buck2 via Kotlin's experimental Build Tools API, making some large Android modules build up to 3x faster and improving incremental build times about 30% for the average developer.
- [Translating Java to Kotlin at Scale](https://swe.quest/articles/translating-java-to-kotlin-at-scale-3648a1737157b36f.md): Meta Engineering · 2024-12-18 · Medium · 13 min read · Java & JVM, Refactoring & migrations, Mobile, Static analysis, Developer tools
  Meta is translating roughly ten million lines of Android Java to Kotlin using the Kotlinator, an automated pipeline built around a headless version of JetBrains' J2K.

Browse: [Latest posts](https://swe.quest/index.md) · [Topics](https://swe.quest/tags.md) · [Sources](https://swe.quest/sources.md) · [Topic map](https://swe.quest/map.md) · [Site guide (llms.txt)](https://swe.quest/llms.txt)
