Dagger dependencies when overriding graph with mock module causes NoClassDefFoundError

爱⌒轻易说出口 提交于 2019-12-13 17:18:49

问题


I am am migrating project to dagger 1.2.2. I'd like to override some dependencies for functional tests. For that I included the dagger-compiler as a dependency of the androidTest-build(?) as well:

apt "com.squareup.dagger:dagger-compiler:$daggerVersion"
compile "com.squareup.dagger:dagger:$daggerVersion"
androidTestApt "com.squareup.dagger:dagger-compiler:$daggerVersion

Now the compiler complains that he cannot find a class (I guess because both builds now contain the transitive dependencies of dagger-compiler):

Error:Execution failed for task ':app:compileDebugAndroidTestJava'.
> java.lang.NoClassDefFoundError: javax/inject/Scope

Looking around github it seems the approach should work without manually excluding stuff.


回答1:


Nevermind. Actually reading the whole buildfile helps alot.

Because of previous dependency-foo I had a directive that excluded the missing dependency explicitly:

configurations {
    androidTestCompile.exclude(group:'javax.inject')
}

Removing that fixed it.



来源:https://stackoverflow.com/questions/30896585/dagger-dependencies-when-overriding-graph-with-mock-module-causes-noclassdeffoun

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!