Download the Android Support Repository

First, make sure the latest version of the Android Support Repository is downloaded via the SDK Manager or Android Studio.

Android Support Repository screenshot

Android SDK Manager in Android Studio

Gradle dependencies

Add these to your app’s build.gradle file. Usually in app/build.gradle.

// Android JUnit Runner
androidTestCompile 'com.android.support.test:runner:0.5'

// JUnit4 Rules
androidTestCompile 'com.android.support.test:rules:0.5'

// Espresso core
androidTestCompile 'com.android.support.test.espresso:espresso-core:2.2.2'
// Espresso-contrib for DatePicker, RecyclerView, Drawer actions, Accessibility checks, CountingIdlingResource
androidTestCompile 'com.android.support.test.espresso:espresso-contrib:2.2.2'
// Espresso-web for WebView support
androidTestCompile 'com.android.support.test.espresso:espresso-web:2.2.2'
// Espresso-idling-resource for synchronization with background jobs
androidTestCompile 'com.android.support.test.espresso:espresso-idling-resource:2.2.2'
// Espresso-intents for validation and stubbing of Intents
androidTestCompile 'com.android.support.test.espresso:espresso-intents:2.2.2'

// UiAutomator
androidTestCompile 'com.android.support.test.uiautomator:uiautomator-v18:2.1.2'

Static jars

For projects that don’t use the Gradle build system: