匕首依赖覆盖图故作模块导致的NoClassDefFoundError当 [英] Dagger dependencies when overriding graph with mock module causes NoClassDefFoundError
问题描述
我正在迁移项目匕首1.2.2。我想重写一些依赖于功能测试。对于我包括匕首编译为androidTest建造的依赖,以及(?):
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
环顾github上看来的方法应该没有手动排除的东西的工作。
Looking around github it seems the approach should work without manually excluding stuff.
推荐答案
没关系。其实在阅读整个构建文件帮助了很多东西。
Nevermind. Actually reading the whole buildfile helps alot.
由于previous依赖-富的我做了一个指令,明确排除缺少的依赖关系:
Because of previous dependency-foo I had a directive that excluded the missing dependency explicitly:
configurations {
androidTestCompile.exclude(group:'javax.inject')
}
去除固定它。
这篇关于匕首依赖覆盖图故作模块导致的NoClassDefFoundError当的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!