Dagger: Allow usage modules without @InstallIn

Created on 12 Jun 2020  路  3Comments  路  Source: google/dagger

In my project I use such structure of Dagger modules:

### @InstallIn(GuestSubComponent::class)
@Module(
    includes = [
        UnitsModuleBinds::class,
        UnitsModuleProvides::class
    ],
    subcomponents = []
)
class UnitsModule

@Module(includes = [], subcomponents = [])
internal abstract class UnitsModuleBinds { }

@Module(includes = [], subcomponents = [])
internal class UnitsModuleProvides { }

I tried migrate this to Hilt from Dagger Android (Add @InstallIn(GuestSubComponent::class) to top module) but received this error:

com.steiner.btmmovies.fetcher.store.UnitsModule must also be annotated with @InstallIn.
  [Hilt] Processing did not complete. See error above for details./Users/uorlak/Documents/Projects/btm-movies/app/build/tmp/kapt3/stubs/debug/com/uorlak/btmmovies/fetcher/store/UnitsModuleBinds.java:32: error: [Hilt]

com.steiner.btmmovies.fetcher.store.UnitsModuleBinds must also be annotated with @InstallIn.
  [Hilt] Processing did not complete. See error above for details./Users/uorlak/Documents/Projects/btm-movies/app/build/tmp/kapt3/stubs/debug/com/uorlak/btmmovies/data/DataModuleProvides.java:19: error: [Hilt]

I think if I add @InstallIn to child modules it will be work, but will be good opportunity if usage not annotated plain modules as child.

Most helpful comment

Hilt has an API for disabling the check that can be useful for migrations. See https://dagger.dev/hilt/compiler-options

You can either completely disable it with a compiler option or use the @DisableInstallInCheck annotation.

All 3 comments

Hilt has an API for disabling the check that can be useful for migrations. See https://dagger.dev/hilt/compiler-options

You can either completely disable it with a compiler option or use the @DisableInstallInCheck annotation.

@danysantiago I think its that I need!
Sorry, my omission, thanks for the tip))

I'll update the error message to point to that page.

Was this page helpful?
0 / 5 - 0 ratings