Dagger2 cannot access nullable. javax.annotation.Nullable not found

烈酒焚心 提交于 2019-12-05 05:08:48

I was getting the javax.annotation.Nullable not found error, which I was able to fix by adding in the findbugs library which includes the Nullable annotation.

If you are using gradle add the following dependency:

implementation 'com.google.code.findbugs:jsr305:3.0.2'

IdService cannot be provided without an @Provides or @Produces annotated method.

This is because you have not injected your dependency where IdService is present. So dagger doesn't know how to provide IdService to it.

The NetModule is used with NetComponent Which is injected in the application and stored in the applications companion object.

You have to inject the dependencies where you want it to be used (here your Activity)

So write the injection in your Activity's OnCreate

netComponent = DaggerNetComponent.builder()
        .netModule(NetModule("some_url"))
        .build()
        .inject(this)
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!