Dagger类的生成

来源:2-13 RxLifecycle配置及使用

悠闲生活

2018-09-09

我使用Dagger2,其中AppComponent和ActivityComponent都能生成相应的Dagger类,但是UserComponent怎么也生不成Dagger类。重新编译了无数次,清除重写,还是不行。为什么呢
@Component(modules = [UserModule::class])
interface RegisterComponent {
fun inject(activity: RegisterActivity)

}

经过不断测试发现,只能在BaseLibrary这个module中才能生成Daggercomponent 类,在其他的module中不行,是不配置的问题呢,因为对Dagger所有的依赖文件都在BaseLibrary的build.gradle中

写回答

1回答

雷宇

2018-09-10

没有添加apt "xxxx.dagger"吧。注解处理器是每个模块都需要添加的,才能查找相应的注解,生成代码。

0
1
悠闲生活
非常感谢!确实如此
2018-09-11
共1条回复

Kotlin打造完整电商APP 模块化+MVP+主流框架

全网稀缺Kotlin项目实战,打造新一代Android工程师的核心竞争力

694 学习 · 209 问题

查看课程