[英]Dagger don't generate component for androidTest
I'm facing a problema with the component dagger generation, I want to generate the component for androidTest, but when I build the project, the DaggerTestComponent it's not generated.我面临着组件匕首生成的问题,我想为 androidTest 生成组件,但是当我构建项目时,它没有生成 DaggerTestComponent。
Component:成分:
package com.test.feliperibeirosaruhashi.testingkotlindagger
import dagger.Component
@Component(modules = arrayOf(MockTestModule::class))
interface MockAppComponent {
fun inject(mainActivityTest:MainActivityTest)
}
build.gradle:构建.gradle:
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:25.1.0'
testCompile 'junit:junit:4.12'
compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
compile "com.android.support:appcompat-v7:$SUPPORT_LIBRARY_VERSION"
compile "com.android.support:design:$SUPPORT_LIBRARY_VERSION"
compile "com.google.dagger:dagger:$DAGGER_VERSION"
kapt "com.google.dagger:dagger-compiler:$DAGGER_VERSION"
provided 'org.glassfish:javax.annotation:10.0-b28'
kaptTest "com.google.dagger:dagger-compiler:$DAGGER_VERSION"
kaptAndroidTest "com.google.dagger:dagger-compiler:$DAGGER_VERSION"
androidTestCompile "com.google.dagger:dagger:$DAGGER_VERSION"
androidTestCompile "com.android.support.test:runner:$RUNNER_VERSION"
androidTestCompile "com.android.support.test:rules:$RUNNER_VERSION"
androidTestCompile "org.mockito:mockito-core:$MOCKITO_VERSION"
androidTestCompile "com.android.support.test.espresso:espresso-core:$ESPRESSO_VERSION"
androidTestCompile "com.android.support.test.espresso:espresso-intents:$ESPRESSO_VERSION"
androidTestCompile "com.crittercism.dexmaker:dexmaker:$DEXMAKER_VERSION"
androidTestCompile "com.crittercism.dexmaker:dexmaker-dx:$DEXMAKER_VERSION"
androidTestCompile "com.crittercism.dexmaker:dexmaker-mockito:$DEXMAKER_VERSION"
}
I put the full project on github: https://github.com/felipesaruhashi/TestingKotlinDagger我把完整的项目放在 github 上: https : //github.com/felipesaruhashi/TestingKotlinDagger
This is caused by an issue in kapt .这是由kapt 中的问题引起的。 The fix for it targets
1.0.7
, 1.1-Beta
.它的修复针对
1.0.7
、 1.1-Beta
。
As a temporary workaround (until fix gets released) one could move MockAppComponent
and related sources in to main
source set.作为一种临时解决方法(直到修复发布),可以将
MockAppComponent
和相关源移动到main
源集中。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.