nextcloud / nextcloud/android

Use Hilt for Dagger configuration

Open
#9,996 2 comments 0 reactions 0 assignees View on GitHub
enhancement technical debt
Dominant language
Kotlin
Stars
5.6k
Forks
2k
Avg merge
2d 18h
Merged PRs (30d)
92

Description

Reference: https://developer.android.com/training/dependency-injection/hilt-android
Migration guide: https://dagger.dev/hilt/migration-guide.html

This will ease most of the Dagger handling, in a standard way and without having to manage custom classes (most of our `di` package will become unnecessary as it's handled by Hilt).

Outline of expected changes:
- `ActivityInjector/FragmentInjector` + `Injectable` get replaced by `@AndroidEntryPoint` annotation on fragments/activities. This also autogenerates `ComponentsModule` for us.
- `MainApp` is annotated with `@HiltAndroidApp` and DI initialization code is not needed anymore
- `Component`s are autogenerated, just need to use `@InstallIn(SingletonComponent)` or equivalent in module declarations. List of available components here: https://dagger.dev/hilt/components.html
- Custom `ViewModelFactory`, `ViewModelModule` and related classes not needed anymore, annotate VMs with `@HiltViewModel` and use normal `ViewmodelProvider` in fragments/activities

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.