From 5341ef8cd758cdc04c74636237da01f4b0c7fc01 Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Fri, 5 Sep 2025 14:37:44 +0200 Subject: [PATCH] Add documentation to migrate from Dagger/Anvil to Metro --- docs/migration_to_metro.md | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 docs/migration_to_metro.md diff --git a/docs/migration_to_metro.md b/docs/migration_to_metro.md new file mode 100644 index 0000000000..23c5db9709 --- /dev/null +++ b/docs/migration_to_metro.md @@ -0,0 +1,15 @@ +# Migration to Metro + +The dependency injection library is now [Metro](https://zacsweers.github.io/metro/latest/). It replaces both Dagger and Anvil. + +Migration of the current Element X code has been performed in https://github.com/element-hq/element-x-android/pull/5253. + +To migrate other existing code you will need to: + +- replace `setupAnvil()` with `setupDependencyInjection()` in your `build.gradle.kts` files +- replace the Dagger and Anvil imports with Metro ones +- move the `@Inject` apply to the constructor to the class itself (only applicable if there is only one primary constructor +- replace `@AssistedInject` with `@Inject` +- replace `@Module` with `@BindingContainer` + +This should help to migrate your existing code.