当在Dagger 2.24中编译下面的代码时,一切工作正常。然而,当编译器在Dagger 2.25中运行时,它会在声明java.lang.NoClassDefFoundError: dagger/shaded/auto/common/BasicAnnotationProcessor时出错
我错过什么了吗?
注意:我使用
implementation "com.google.dagger:dagger:2.24"
kapt "com.google.dagger:dagger-compiler:2.24"
// Change 2.24 to 2.25, the error occurs.fun main() {
val myClass = MyClass()
}
class MyClass {
@Inject
lateinit var stringMe: String
init {
DaggerMyComponent.create().subComponent().inject(this)
println(stringMe)
}
}
@Component
interface MyComponent {
fun subComponent(): MySubcomponent
// fun inject(a: MyClass)
}
@Subcomponent(modules = [MeSubModule::class])
interface MySubcomponent {
fun inject(a: MyClass)
}
@Module
class MeSubModule {
@Provides
fun stringMe(): String = "Hi here"
}发布于 2019-10-24 09:43:20
这是Dagger 2的问题。要在https://github.com/google/dagger/releases/tag/dagger-2.25.2中修复
https://stackoverflow.com/questions/58522687
复制相似问题