Context cannot be provided without an @Provides-annotated method, but it is?

爷,独闯天下 提交于 2019-11-30 17:48:40

After quite a while of trial and error I've seem to found the cause, it's the ambiguity of Context because @ForApplication is missing in some places where Context is needed.

Also it may be my frail understanding of Dagger2 at the moment, but this boilerplate is quite prone to developer errors.

Anyhow... for anyone that finds the problem you just have to add the qualifier annotations in every place that dependency is used:

@Singleton
@Component(
        modules = ApplicationModule.class
)
public interface ApplicationComponent {

    CustomApplication getCustomApplication();

    @ForApplication Context getApplicationContext();

}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!