当我们使用Dagger和Kotlin时,需要在我们的build.gradle依赖项中添加以下内容。
我发现 https://dev59.com/CFoV5IYBdhLWcg3wc-jo#36231516 提供了有关如何获取生成的DaggerTestComponent的说明,并尝试将以下内容放入我的依赖项中。
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进行测试,并生成DaggerTestComponent.builder()
,如https://labs.ribot.co.uk/fast-and-reliable-ui-tests-on-android-17c261b8220c#.o3efc5knx或者https://medium.com/@fabioCollini/android-testing-using-dagger-2-mockito-and-a-custom-junit-rule-c8487ed01b56#.hxtytfns3
中所述,在Kotlin语言中,却遇到以下错误
Error:(14, 25) Unresolved reference: DaggerTestComponent
我发现 https://dev59.com/CFoV5IYBdhLWcg3wc-jo#36231516 提供了有关如何获取生成的DaggerTestComponent的说明,并尝试将以下内容放入我的依赖项中。
androidTestApt 'com.google.dagger:dagger-compiler:2.0.1'
显然,我认为这是针对Java而不是Kotlin的,因此问题仍然存在。是否有Kotlin版本?如何在我的Kotlin项目中生成DaggerTestComponent
?