I\'m configuring the new Dagger Android module but I got this error Here\'s my Component:
@AppScope
@Component(modules = {AppModule.class, NetModule.class})
Remove the below code from the AppModule.class and rebuild the project
@Provides
@Singleton
Application provideContext(SomeApplication application) {
return application;
}
I think this provides a somewhat clearer explanation on the use of @BindsInstance
and removal of @Provides Application
, Dagger 2 Component Builder:
@BindsInstance
What?Here’s the definition :
Marks a method on a component builder or subcomponent builder that allows an instance to be bound to some type within the component. — source
WHAAT? I don’t understand it either
In my case I was using an object Module, so I had to annotate provider method with @JvmStatic
@Module
object GsonModule {
@JvmStatic
@Singleton
@Provides
fun provideGson() = Gson()
}