lundi 8 mai 2017

Dagger2 "test" class generated but not able to import it

So basically I can see that my DaggerTestComponent is generated in apt/adnroidTest/debug/...

but I can't import it, it keep saying cannot resolve symbol...

public class TestComponentRule implements TestRule {

private final TestComponent mTestComponent;
private final Context mContext;

public TestComponentRule(Context context) {
    mContext = context;
    LGCApplication application = LGCApplication.get(context);
    mTestComponent = DaggerTestComponent.builder()
            .applicationTestModule(new ApplicationTestModule(application))
            .build();
}

And for the revelant part of the gradle:

android {
    sourceSets {
        def commonTestDir = 'src/commonTest/java'
        test {
            java.srcDir commonTestDir
        }
        androidTest {
            java.srcDir commonTestDir
        }
    }
}

dependencies {
    compile "com.google.dagger:dagger:2.9"
    annotationProcessor "com.google.dagger:dagger-compiler:2.9"
    testAnnotationProcessor "com.google.dagger:dagger-compiler:2.9"
    androidTestAnnotationProcessor "com.google.dagger:dagger-compiler:2.9"
    provided 'org.glassfish:javax.annotation:10.0-b28' //Required by Dagger2
}

And it's only for the testComponent, the DaggerComponent for my application is added successfully.

Aucun commentaire:

Enregistrer un commentaire