Updated to Espresso 2.1 and now there is a dependency conflict
While configuring Espresso 2.1 and the latest version of the Android Testing Support Library, I encountered the following warning on build:
Confilct with dependency 'com.android.support:support-annotations'. Solved versions of app and test app are different
My build.gradle file:
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'
}
In fact, I found an existing problem :
we built against the old 22.0.0 and did not upgrade to 22.1.0. The runner depends on com.android.support:support-annotations:22.0.0 which conflicts with the latest support library version (22.1.0)
I told gradle which version of support annotations to resolve by adding the following line to the list of dependencies:
androidTestCompile 'com.android.support:support-annotations:22.1.0'
and the warning did not pass.
@appoll Here Stefan Linzner added a workaround for this.
Above, I added my comment to this issue, which explains the solution:
we are aware of this problem. The bottom line is that the runner depends on com.android.support:support-annotations:22.0.0 which conflicts with the latest support library (22.1.0). The correct way to solve this right now is to tell Gradle which version of the support annotations to resolve.