未解决的参考:DaggerTestComponent(Kotlin with Dagger for Test)
Unresolved reference: DaggerTestComponent (Kotlin with Dagger for Test)
当我们使用 Dagger 和 Kotlin 时,我们的 build.gradle 依赖项中需要以下内容
kapt 'com.google.dagger:dagger-compiler:2.0'
compile 'com.google.dagger:dagger:2.0'
provided 'org.glassfish:javax.annotation:10.0-b28'
如http://www.beyondtechnicallycorrect.com/2015/12/30/android-kotlin-dagger/
所述
当我尝试使用 Dagger 执行测试,并按照 https://labs.ribot.co.uk/fast-and-reliable-ui-tests-on-android-17c261b8220c#.o3efc5knx or even https://medium.com/@fabioCollini/android-testing-using-dagger-2-mockito-and-a-custom-junit-rule-c8487ed01b56#.hxtytfns3 以 Kotlin 语言生成 DaggerTestComponent.builder()
时,出现以下错误
Error:(14, 25) Unresolved reference: DaggerTestComponent
我发现 解释了如何生成 DaggerTestComponent,并尝试将以下内容放入我的依赖项中。
androidTestApt 'com.google.dagger:dagger-compiler:2.0.1'
显然,我认为这是针对 Java 而不是 Kotlin,所以问题仍然存在。它有 Kotlin 版本吗?如何在我的 Kotlin 项目中生成我的 DaggerTestComponent
?
从 Kotlin Slack 频道找到了答案。感谢 Kirill Rakhman。
是(器测)
kaptAndroidTest 'com.google.dagger:dagger-compiler:2.0.2'
或(用于单元测试)
kaptTest 'com.google.dagger:dagger-compiler:2.0.2'
当我们使用 Dagger 和 Kotlin 时,我们的 build.gradle 依赖项中需要以下内容
kapt 'com.google.dagger:dagger-compiler:2.0'
compile 'com.google.dagger:dagger:2.0'
provided 'org.glassfish:javax.annotation:10.0-b28'
如http://www.beyondtechnicallycorrect.com/2015/12/30/android-kotlin-dagger/
所述当我尝试使用 Dagger 执行测试,并按照 https://labs.ribot.co.uk/fast-and-reliable-ui-tests-on-android-17c261b8220c#.o3efc5knx or even https://medium.com/@fabioCollini/android-testing-using-dagger-2-mockito-and-a-custom-junit-rule-c8487ed01b56#.hxtytfns3 以 Kotlin 语言生成 DaggerTestComponent.builder()
时,出现以下错误
Error:(14, 25) Unresolved reference: DaggerTestComponent
我发现
androidTestApt 'com.google.dagger:dagger-compiler:2.0.1'
显然,我认为这是针对 Java 而不是 Kotlin,所以问题仍然存在。它有 Kotlin 版本吗?如何在我的 Kotlin 项目中生成我的 DaggerTestComponent
?
从 Kotlin Slack 频道找到了答案。感谢 Kirill Rakhman。
是(器测)
kaptAndroidTest 'com.google.dagger:dagger-compiler:2.0.2'
或(用于单元测试)
kaptTest 'com.google.dagger:dagger-compiler:2.0.2'