Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Studio doesn't recognize Espresso classes

Tags:

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:

external libraries

like image 633
midnight Avatar asked Mar 07 '14 09:03

midnight


1 Answers

So this is basically a bug with Android Studio (i'm guessing).

Reference:

  1. Issue raised in adt-dev groups
  2. Actual bug - #66841

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'     } } 
like image 69
Kaushik Gopal Avatar answered Sep 20 '22 00:09

Kaushik Gopal