At the heart of instrumented UI testing lies the Android Testing Support Library. This includes the JUnit APIs, a UI Automator and the Espresso testing framework. There is virtually nothing involved in setting Espresso up on Android Studio, as it is included as a dependency by default if you are working on a project generated by the project setup wizard. If not, you will need to add the following to your build.gradle file:
androidTestImplementation('com.android.support.test.espresso:espresso-core:2.2.2', { exclude group: 'com.android.support', module: 'support-annotations' })