Dagger 2不会生成组件类(Android,Kotlin)
基本上,我想测试TheCoffee
被自动“注入”。 但是我找不到DaggerMyComponent
。 我想我一定做错了什么,但是什么?
在MainActivity下,
@Component(modules=arrayOf(MyModule::class)) @Singleton interface MyComponent { fun inject(coffee: CoffeeShop) } @Module class MyModule { @Provides @Singleton @ForApplication fun provideCoffee():Coffee { return Coffee("Bad coffee"); } } data class Coffee(var Name:String) class CoffeeShop { @Inject var TheCoffee:Coffee? = null; } @Qualifier @Retention(AnnotationRetention.RUNTIME) annotation class ForApplication
的build.gradle
apply plugin: 'kotlin-kapt' ... kapt { generateStubs = true } .... dependencies { compile 'com.google.dagger:dagger-android:2.13' kapt 'com.google.dagger:dagger-android-processor:2.13' compileOnly 'com.google.dagger:dagger:2.13' kapt 'com.google.dagger:dagger-compiler:2.13'
- 无法转换为org.jetbrains.kotlin.java.model.types.JeClassInitializerExecutableTypeMirror
- Moshi的定制适配器与RxAndroid&Retrofit&Kotlin
- Retrofit 2.0如何获得反序列化的错误response.body
- 未解决的参考匕首2 + kotlin + android gradle
- Android Dagger:我无法提供没有@Inject构造函数的外部类
- Dagger2和Kotlin运行失败的原因是:app:compileDebugKotlinAfterJava
- 匕首2,不能在我的活动中注入演示者
- Kapt generatestubs – 不能用单元测试的内部构造函数初始化对象
- 新的建筑与匕首和Kotlin