Update (9/07/2015):
You can continue to work with 22.2.1 if you use the following excludes:
androidTestCompile ('com.android.support.test.espresso:espresso-core:2.2') {
exclude group: 'com.android.support', module: 'support-annotations'
}
androidTestCompile ('com.android.support.test:runner:0.3') {
exclude group: 'com.android.support', module: 'support-annotations'
}
androidTestCompile ('com.android.support.test:rules:0.3') {
exclude group: 'com.android.support', module: 'support-annotations'
}
If you depend on espresso-contrib
, you need the exclude as well.
Update (8/03/2015):
With support library 22.2.1, the dependencies are broken again; please don't upgrade to 22.2.1 until a new runner is released.
Update (6/04/2015):
With the latest release of runner 0.3 and rules 0.3, this answer is no longer needed. You can simply use
androidTestCompile 'com.android.support.test:runner:0.3'
androidTestCompile 'com.android.support.test:rules:0.3'
androidTestCompile 'com.android.support.test.espresso:espresso-core:2.2'
with latest support libraries. (22.2.0
as of this writing)
Update (5/30/2015):
compile 'com.android.support:appcompat-v7:22.2.0'
androidTestCompile 'com.android.support.test.espresso:espresso-core:2.2'
// com.android.support.test:testing-support-lib:0.1 // <-- causes issue
Update (4/24/2015):
The problem is that com.android.support:support-v4:22.1.1
is clashing with com.android.support.test:runner:0.2
(as that depends on com.android.support:support-v4:22.0.0
).
com.android.support.test.espresso:espresso-core:2.1
has a dependency on com.android.support.test:runner:0.2
, so it also causes the same error.
So, this combination will work:
compile 'com.android.support:support-v4:22.0.0'
androidTestCompile 'com.android.support.test.espresso:espresso-core:2.1'
...and so will this one (without 'com.android.support.test:runner:0.2'
):
compile 'com.android.support:support-v4:22.1.0'
androidTestCompile 'com.android.support.test.espresso:espresso-core:2.0'
Original Answer:
Contrary to what the Espresso documentation says, you should remove this dependency:
androidTestCompile 'com.android.support.test:runner:0.2'
As it is the cause for library version conflict.
You should also update to Android gradle plugin 1.1.1, as that version will tell you the exact version conflict, which is useful in this case.