title: Why these errors appear when running Android Espresso UI tests?
body: <p>I'm trying to run Instrumentation android UI test using espresso but I am getting these errors. </p>
  
  <pre><code>Error:(3, 33) error: package android.support.test.rule does not exist
  Error:(4, 35) error: package android.support.test.runner does not exist
  Error:(7, 17) error: package org.junit does not exist
  Error:(8, 17) error: package org.junit does not exist
  Error:(9, 24) error: package org.junit.runner does not exist
  Error:(13, 44) error: package android.support.test.espresso does not exist
  Error:(13, 1) error: static import only from classes and interfaces
  Error:(14, 1) error: static import only from classes and interfaces
  Error:(14, 51) error: package android.support.test.espresso.action does not exist
  Error:(15, 54) error: package android.support.test.espresso.assertion does not exist
  Error:(15, 1) error: static import only from classes and interfaces
  Error:(16, 52) error: package android.support.test.espresso.matcher does not exist
  Error:(16, 1) error: static import only from classes and interfaces
  Error:(17, 52) error: package android.support.test.espresso.matcher does not exist
  Error:(17, 1) error: static import only from classes and interfaces
  Error:(19, 2) error: cannot find symbol class RunWith
  Error:(24, 12) error: cannot find symbol class ActivityTestRule
  Error:(23, 6) error: cannot find symbol class Rule
  Error:(26, 6) error: cannot find symbol class Test
  Error:Execution failed for task ':westwing:compileStageDebugJavaWithJavac'.
  &gt; Compilation failed; see the compiler error output for details.
  </code></pre>
  
  <p>I followed the steps here:
  <a href="https://google.github.io/android-testing-support-library/docs/espresso/setup/" rel="nofollow">https://google.github.io/android-testing-support-library/docs/espresso/setup/</a></p>
  
  <p>Gradle file :</p>
  
  <pre><code>apply plugin: 'com.android.application'
  
  android {
      compileSdkVersion 23
      buildToolsVersion '23.0.2'
  
  
      defaultConfig {
          applicationId "de.westwing.android"
          minSdkVersion 10
          targetSdkVersion 23
          signingConfig signingConfigs.dumpKey
  
          testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
      }
  
      buildTypes {
          release {
              // The ProGuard plugin is applied automatically, and the tasks are created automatically
              // if the Build Type is configured to run ProGuard through the minifyEnabled property.
              minifyEnabled false
              shrinkResources true
              proguardFiles getDefaultProguardFile('proguard-android.txt'),
                      'proguard-rules.txt'
              debuggable false
          }
          debug {
              debuggable true
          }
      }
  
      productFlavors {
          live {
              manifestPlaceholders = [appIcon: "@mipmap/ic_launcher", appName: "@string/app_name"]
              buildConfigField "boolean", "STAGE", "false"
          }
          stage {
              manifestPlaceholders = [appName: getWorkingBranch(), appIcon: "@drawable/ic_stage_launcher"]
              applicationId "de.westwing.android.stage"
              buildConfigField "boolean", "STAGE", "true"
          }
      }
  
  
  }
  
  dependencies {
      compile project(':appoxee')
      compile project(':android-volley-master')
  
      compile 'com.squareup.okhttp:okhttp:1.6.0'
      compile 'com.google.code.gson:gson:2.3'
      compile 'com.android.support:support-annotations:23.1.1'
      compile 'com.google.android.gms:play-services-base:8.1.0'
      compile 'com.google.android.gms:play-services-plus:8.1.0'
      compile 'com.google.android.gms:play-services-analytics:8.1.0'
      compile 'com.google.android.gms:play-services-identity:8.1.0'
      compile 'com.google.android.gms:play-services-gcm:8.1.0'
      compile 'com.android.support:gridlayout-v7:23.1.0'
      compile 'com.android.support:cardview-v7:23.1.0'
      compile 'com.android.support:recyclerview-v7:23.1.0'
      compile 'com.facebook.android:facebook-android-sdk:4.5.0'
      compile 'com.jakewharton:butterknife:6.1.0'
      compile 'io.card:android-sdk:5.1.1'
      compile 'com.adjust.sdk:adjust-android:4.1.2'
      compile 'com.intellij:annotations:12.+'
      compile 'com.android.support:design:23.1.0'
      compile 'com.github.chrisbanes.photoview:library:1.2.4'
      compile 'de.greenrobot:eventbus:2.4.0'
      compile 'com.crittercism:crittercism-android-agent:5.4.0'
      compile 'com.android.support:percent:23.1.0'
      compile('com.github.worker8:tourguide:1.0.14-SNAPSHOT@aar') {
          transitive = true
      }
      compile 'net.hockeyapp.android:HockeySDK:3.6.0'
  
      // Crashlytics Kit
      compile('com.crashlytics.sdk.android:crashlytics:2.3.2@aar') {
          transitive = true
      }
  
      compile files('libs/FlurryAnalytics-5.6.0.jar')
      compile files('libs/appsee.jar')
  
      testCompile 'junit:junit:4.12'
      testCompile 'org.mockito:mockito-core:1.10.19'
      testCompile 'org.hamcrest:hamcrest-library:1.1'
      testCompile 'org.robolectric:robolectric:3.0'
  
      androidTestCompile 'com.android.support:support-annotations:23.1.1'
      androidTestCompile 'com.android.support.test:runner:0.4.1'
      androidTestCompile 'com.android.support.test:rules:0.4.1'
      androidTestCompile 'com.android.support.test.espresso:espresso-core:2.2.1'
      // Set this dependency if you want to use Hamcrest matching
      androidTestCompile 'org.hamcrest:hamcrest-library:1.3'
  }
  
  buildscript {
      repositories {
          maven { url 'https://maven.fabric.io/public' }
      }
  
      dependencies {
          classpath 'io.fabric.tools:gradle:1.+'
      }
  }
  
  repositories {
      maven { url "https://maven.fabric.io/public" }
      maven { url "https://oss.sonatype.org/content/repositories/snapshots" }
  }
  
  android {
      useLibrary 'org.apache.http.legacy'
  }
  android { sourceSets { main { java.srcDirs = ['src/main/java', 'src/androidTest/java'] } } }
  </code></pre>
  
  <p>and here is my test :</p>
  
  <pre><code>package de.westwing.android;
  
  import android.support.test.rule.ActivityTestRule;
  import android.support.test.runner.AndroidJUnit4;
  import android.test.suitebuilder.annotation.LargeTest;
  
  import org.junit.Rule;
  import org.junit.Test;
  import org.junit.runner.RunWith;
  
  import de.westwing.android.presentation.activities.MainActivity;
  
  import static android.support.test.espresso.Espresso.onView;
  import static android.support.test.espresso.action.ViewActions.click;
  import static android.support.test.espresso.assertion.ViewAssertions.matches;
  import static android.support.test.espresso.matcher.ViewMatchers.isDisplayed;
  import static android.support.test.espresso.matcher.ViewMatchers.withId;
  
  @RunWith(AndroidJUnit4.class)
  @LargeTest
  public class NavigationViewTest {
  
      @Rule
      public ActivityTestRule&lt;MainActivity&gt; mActivityRule = new ActivityTestRule(MainActivity.class);
  
      @Test
      public void testNavigationViewItems() {
          onView(withId(R.id.nav_email_customer_service))            // withId(R.id.my_view) is a ViewMatcher
                  .perform(click())               // click() is a ViewAction
                  .check(matches(isDisplayed())); // matches(isDisplayed()) is a ViewAssertion
      }
  }
  </code></pre>