I'm running Android Studio 0.5.0
with Gradle 1.11
. I'm trying to install Espresso library from com.jakewharton.espresso:espresso:1.1-r2. For some reason AS couldn't recognize Espresso classes after project synchronization. So every time I try to import import static com.google.android.apps.common.testing.ui.espresso.Espresso.onView;
inside androidTest
folder files it marks it as invalid.
Here's my build.gradle:
apply plugin: 'android'
android {
compileSdkVersion 19
buildToolsVersion '19.0.2'
defaultConfig {
minSdkVersion 14
targetSdkVersion 19
versionCode 1
versionName "1.0"
testInstrumentationRunner "com.google.android.apps.common.testing.testrunner.GoogleInstrumentationTestRunner"
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
dependencies {
compile 'com.squareup.dagger:dagger-compiler:1.2.1'
compile 'com.squareup.dagger:dagger:1.2.1'
androidTestCompile ('com.jakewharton.espresso:espresso:1.1-r2') {
exclude group: 'com.squareup.dagger'
}
}
External libraries:
So this is basically a bug with Android Studio (i'm guessing).
Reference:
Workaround (until the bug is fixed):
Add a duplicate provided dependency in your gradle file like so:
dependencies {
// ...
provided 'com.jakewharton.espresso:espresso:1.1-r2'
androidTestCompile ('com.jakewharton.espresso:espresso:1.1-r2') {
exclude group: 'com.squareup.dagger'
}
}