Skip to content

Most visited

Recently visited

navigation

Packages

Adding Gradle dependencies from a Maven repository

In order to use the Android Testing Support Library (ATSL), you must modify your app project's classpath dependencies within your development environment, as shown in the following steps:

  1. Open the build.gradle file for your app.
  2. In the repositories section, add Google's Maven repository. To do so, add a maven section with the "https://maven.google.com" endpoint. For example:

    allprojects {
        repositories {
            jcenter()
            maven {
                url "https://maven.google.com"
            }
        }
    }
  3. For each ATSL package you want to use, add its package name to the dependencies section. For example, to add the espresso-core package, add the following lines:

    dependencies {
        ...
        androidTestCompile 'com.android.support.test.espresso:espresso-core:3.0.1'
    }

    Caution: Using dynamic dependencies (for example, espresso-core:3.0.0+) can cause unexpected version updates and regression incompatibilities. We recommend that you explicitly specify a particular version number (for example, espresso-core:3.0.0).

List of Android Testing Support Library dependencies

The Android Testing Support Library (ATSL) includes many dependencies. As discussed in Adding Gradle dependencies from a Maven repository, you can add these dependencies to your development environment by adding each dependency within your module-level build.gradle file.

The following dependencies are available in ATSL:

dependencies {
  // AndroidJUnitRunner and JUnit Rules
  androidTestCompile 'com.android.support.test:runner:1.0.1'
  androidTestCompile 'com.android.support.test:rules:1.0.1'

  // Espresso dependencies
  androidTestCompile 'com.android.support.test.espresso:espresso-core:3.0.1'
  androidTestCompile 'com.android.support.test.espresso:espresso-contrib:3.0.1'
  androidTestCompile 'com.android.support.test.espresso:espresso-intents:3.0.1'
  androidTestCompile 'com.android.support.test.espresso:espresso-accessibility:3.0.1'
  androidTestCompile 'com.android.support.test.espresso:espresso-web:3.0.1'
  androidTestCompile 'com.android.support.test.espresso.idling:idling-concurrent:3.0.1'

  // The following Espresso dependency can be either "compile"
  // or "androidTestCompile", depending on your app's implementation
  androidTestCompile 'com.android.support.test.espresso:espresso-idling-resource:3.0.1'
}
This site uses cookies to store your preferences for site-specific language and display options.

Get the latest Android developer news and tips that will help you find success on Google Play.

* Required Fields

Hooray!

Follow Google Developers on WeChat

Browse this site in ?

You requested a page in , but your language preference for this site is .

Would you like to change your language preference and browse this site in ? If you want to change your language preference later, use the language menu at the bottom of each page.

This class requires API level or higher

This doc is hidden because your selected API level for the documentation is . You can change the documentation API level with the selector above the left navigation.

For more information about specifying the API level your app requires, read Supporting Different Platform Versions.

Take a short survey?
Help us improve the Android developer experience.
(Sep 2017 survey)