Dagger不会为androidTest生成组件
我正在面对组件匕首生成的问题,我想为androidTest生成组件,但是当我生成项目时,DaggerTestComponent不会生成。
零件:
package com.test.feliperibeirosaruhashi.testingkotlindagger import dagger.Component @Component(modules = arrayOf(MockTestModule::class)) interface MockAppComponent { fun inject(mainActivityTest:MainActivityTest) }
的build.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" }
我把完整的项目放在github上: https : //github.com/felipesaruhashi/TestingKotlinDagger
- 改进API调用:如何确保在进行api调用后该值不为空?
- 我可以在Kotlin中使用Dagger 2的现场注射吗?
- kotlin限定符注释被忽略
- AndroidInjector <android.app.Activity>不能提供@ Provide或者@ Produces注解的方法
- 改进泛型类型的调用方法
这是由kapt中的问题引起的。 它的目标是1.0.7
1.1-Beta
。
作为一个临时解决方法(直到修复被释放),可以将MockAppComponent
和相关的源代码移到main
源代码集中。
- 使用RxJava + Kotlin解析数据时出错
- Dagger2不注入
- 生成的类未找到
- 匕首2 – 在构造函数中注入默认值
- 如何在AndroidStudio中使用Dagger2和Kotlin在其他项目模块中实现接口库
- Android Studio无法重构“只读”kapt生成的代码
- 错误:未找到注释处理器'__gen.AnnotationProcessorWrapper_debug_android_databinding_annotationprocessor_ProcessDataBinding'
- 来自Retrofit的POST请求以意想不到的方式工作
- Dagger2将演示者注入到Kotlin Activity错误中