I am adding Espresso to my project in Android Studio. I have installed the Support Repository and in fact have already been using pieces of it. Then I added these dependenci
I had this issue as well and I have my android test cases under src/androidTests as recommended by Google, but this caused problems with build.gradle:
sourceSets {
main {
java.srcDirs = ['src']
}
}
With the above it's trying to compile all my test cases within the normal debug compilation target, which does not include the espresso and other dependencies because they're listed under androidTestCompile.
In the end I fixed this by excluding the androidTest subdirectory from compilation and set the root of androidTest to the appropriate directory.
sourceSets {
main {
java.srcDirs = ['src']
java.excludes = ['androidTest/**']
}
androidTest.setRoot('src/androidTest')
}