Dagger+Robolectric+Gradle+APT - source not generated for test module -



Dagger+Robolectric+Gradle+APT - source not generated for test module -

(question available github repo here)

edit: looks issue android-apt not playing nicely robolectric. 'gradle clean assembledebugtest' generate test sources, 'gradle clean test' not. think android-apt need modified work case.

edit 2: solved problem changing temporarily using compile rather apt, androidtestapt, or provided. question remain open though, because shouldn't including stuff in our apks.

i have dependency in project requires android apt plugin. unfortunately, can't test pass when apt plugin applied.

here's brief overview of project structure:

src ├───androidtest/java/com.example.myapplication │ ├───mytest │ ├───testmodule │ └───testmyapplication [extends application] │ └───main/java/com.example.myapplication ├───myapplication └───mymodule

testmyapplication overrides getmodules() method in myapplication , adds testmodule.

my dependencies section looks this:

dependencies { compile 'com.squareup.dagger:dagger:1.2.2' apt 'com.squareup.dagger:dagger-compiler:1.2.2' androidtestapt 'com.squareup.dagger:dagger-compiler:1.2.2' androidtestcompile 'junit:junit:4.11' androidtestcompile 'org.robolectric:robolectric:2.3' }

yet still, error @ runtime:

java.lang.runtimeexception: java.lang.illegalstateexception: module adapter class com.example.myapplication.testmodule not loaded. please ensure code generation run module.

if disable android-apt , utilize provides instead of apt , androidtestapt, works great!

notably, provides not work if android-apt plugin applied.

for finish source, please check out repo here illustrate issue: https://github.com/jacobtabak/robolectric-dagger-skeleton

there 3 branches -

master, original case want work provided, works using provided , has android-apt plugin disabled aptfail, exact same case above, except android-apt plugin applied, fails.

thanks! reply accepted must not used 'compile' dagger compiler.

gradle robolectric apt dagger

Comments

Popular posts from this blog

Delphi change the assembly code of a running process -

json - Hibernate and Jackson (java.lang.IllegalStateException: Cannot call sendError() after the response has been committed) -

C++ 11 "class" keyword -