相关疑难解决方法(0)

Dagger没有为/ test class生成组件

我在这里关注指南:https://github.com/ecgreb/dagger-2-testing-demo

我的app/src/main中有以下设置(省略了注入和@Provides代码):

public class FlingyApplication extends Application {
    @Singleton
    @Component(modules = { FlingyModule.class })
    public interface FlingyComponent
}

@Module
public class FlingyModule
Run Code Online (Sandbox Code Playgroud)

在app/src/test中:

public class TestFlingyApplication extends Application {
    @Singleton
    @Component(modules = { TestFlingyModule.class })
    public interface TestFlingyComponent extends FlingyComponent
}

@Module
public class TestFlingyModule
Run Code Online (Sandbox Code Playgroud)

到目前为止,它几乎与示例github相同.当dagger为src/main中的Component构建器生成代码时,它们会正确生成.但是,Dagger不会在src/test中为Component构建器生成代码.

我的主要build.gradle:

dependencies {
    classpath 'com.android.tools.build:gradle:2.1.0-alpha3'

    classpath 'com.neenbedankt.gradle.plugins:android-apt:1.5.1'
}
Run Code Online (Sandbox Code Playgroud)

我的app/build.gradle

apply plugin: 'com.android.application'
apply plugin: 'com.neenbedankt.android-apt'


android {
    # There is obviously more in here, but this is the custom part:
    packagingOptions …
Run Code Online (Sandbox Code Playgroud)

android dagger-2

59
推荐指数
4
解决办法
1万
查看次数

标签 统计

android ×1

dagger-2 ×1