下面是我的build.gradle
中有冲突的部分:
...
dependencies {
classpath 'com.android.tools.build:gradle:1.1.1'
}
...
testCompile( 'com.squareup.assertj:assertj-android:1.0.0' )
...
我在日志中看到的问题是:
WARNING: Conflict with dependency 'com.android.support:support-annotations'. Resolved versions for app (21.0.3) and test app (20.0.0) differ.
显然,它消除了类路径中的冲突依赖。我不确定是gradle
还是android gradle
插件。
接下来我试过:
testCompile( 'com.squareup.assertj:assertj-android:1.0.0' ) {
exclude group: 'com.android.support', module: 'support-annotations'
}
但是我仍然有编译错误,所以不包括依赖项。
接下来我试过:
configurations.all {
resolutionStrategy {
// fail eagerly on version conflict (includes transitive dependencies)
// e.g. multiple different versions of the same dependency (group and name are equal)
failOnVersionConflict()
// force certain versions of dependencies (including transitive)
// *append new forced modules:
force 'com.android.support:support-annotations:21.0.3'
// *replace existing forced modules with new ones:
forcedModules = ['com.android.support:support-annotations:21.0.3']
}
}
但是看起来它不起作用,因为它在第一次冲突中没有失败,而且我仍然有编译错误。
你的建议是什么?
更新删除依赖项是什么意思??我看到了许多assertj
找不到的编译错误
发布于 2015-02-27 21:48:21
我遇到了同样的问题。这个帮我修好了:
testCompile('com.squareup.assertj:assertj-android:1.0.0'){
exclude group: 'com.android.support', module:'support-annotations'
}
发布于 2015-09-03 22:37:14
接受的答案对我没有用。但是,添加以下内容对我确实有用:
androidTestCompile 'com.android.support:support-annotations:23.0.1'
以及:
testCompile 'com.android.support:support-annotations:23.0.1'
发布于 2015-04-27 13:04:26
你需要改变:
testCompile( 'com.squareup.assertj:assertj-android:1.0.0' ) {
exclude group: 'com.android.support', module: 'support-annotations'
}
至:
compile('com.squareup.assertj:assertj-android:1.0.0') {
exclude group: 'com.android.support', module: 'support-annotations'
}
还要确保您的测试文件夹名为test
,而不是androidTest
。
https://stackoverflow.com/questions/28761748
复制相似问题