While trying to integrate latest Dagger 2 version, I am facing problem of Dagger auto generation. Dagger is not auto generating DaggerAppComponent in spite of several Rebuilds a
Chenge code to this,
private void initAppComponent()
{
/* DaggerAppComponent.builder()
.appModule(new AppModule(this))
.build();*/
appComponent = DaggerAppComponent.builder()
.appModule(new AppModule(this))
.build();
appComponent .inject(this)
}
Other things are
@Singleton
@Component(modules = AppModule.class)
public interface AppComponent
{
void inject(BaseApplication application);
}
Why you need to inject same class where a component is built you can easily get context and application on Application class. Dagger can help you to find a dependent class.