升级到 Espresso 2.1,现在出现依赖冲突
Upgraded to Espresso 2.1 and now getting dependency conflict
在设置 Espresso 2.1 和最新版本的 Android 测试支持库时,我在构建时遇到了下一个警告:
Confilct with dependency 'com.android.support:support-annotations'.
Resolved versions for app and test app differ
我的build.gradle文件是:
apply plugin: 'com.android.application'
android {
...
defaultConfig {
testInstrumentationRunner 'android.support.test.runner.AndroidJUnitRunner'
}
...
}
dependencies {
androidTestCompile 'com.android.support.test:runner:0.2'
androidTestCompile 'com.android.support.test:rules:0.2'
androidTestCompile 'com.android.support.test.espresso:espresso-core:2.1'
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:22.1.0'
}
实际上我找到了一个 existing issue:
we built against the old 22.0.0 and didn't upgrade to 22.1.0.
The runner depends on com.android.support:support-annotations:22.0.0 which conflicts with the latest support library release (22.1.0)
我通过将以下行添加到我的依赖项列表来告诉 gradle 它需要解析哪个版本的支持注释:
androidTestCompile 'com.android.support:support-annotations:22.1.0'
警告消失了。
@appoll Here Stephan Linzner 为此添加了解决方法。
上面我已经添加了他对这个问题的评论,解释了解决方案:
we are aware of the issue. The gist is that the runner depends on com.android.support:support-annotations:22.0.0 which conflicts with the latest support library release (22.1.0). The correct way to solve this right now, is to tell Gradle which version of support-annotations it needs to resolve to.
在设置 Espresso 2.1 和最新版本的 Android 测试支持库时,我在构建时遇到了下一个警告:
Confilct with dependency 'com.android.support:support-annotations'. Resolved versions for app and test app differ
我的build.gradle文件是:
apply plugin: 'com.android.application'
android {
...
defaultConfig {
testInstrumentationRunner 'android.support.test.runner.AndroidJUnitRunner'
}
...
}
dependencies {
androidTestCompile 'com.android.support.test:runner:0.2'
androidTestCompile 'com.android.support.test:rules:0.2'
androidTestCompile 'com.android.support.test.espresso:espresso-core:2.1'
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:22.1.0'
}
实际上我找到了一个 existing issue:
we built against the old 22.0.0 and didn't upgrade to 22.1.0. The runner depends on com.android.support:support-annotations:22.0.0 which conflicts with the latest support library release (22.1.0)
我通过将以下行添加到我的依赖项列表来告诉 gradle 它需要解析哪个版本的支持注释:
androidTestCompile 'com.android.support:support-annotations:22.1.0'
警告消失了。
@appoll Here Stephan Linzner 为此添加了解决方法。
上面我已经添加了他对这个问题的评论,解释了解决方案:
we are aware of the issue. The gist is that the runner depends on com.android.support:support-annotations:22.0.0 which conflicts with the latest support library release (22.1.0). The correct way to solve this right now, is to tell Gradle which version of support-annotations it needs to resolve to.