According to Android Espresso Documentation :
Add espresso options
To add Espresso project dependencies to your project, follow these steps:
- Open the apps build.gradle file. This is usually not a top level build.gradle file, but app / build.gradle.
- Add the following lines inside the dependencies:
androidTestCompile 'com.android.support.test.espresso:espresso-core:3.0.0' androidTestCompile 'com.android.support.test:runner:1.0.0'
I created a new project, and the generated app / gradle file was something like this:
apply plugin: 'com.android.application' android { compileSdkVersion 26 buildToolsVersion "26.0.0" defaultConfig { applicationId "com.app.test" minSdkVersion 24 targetSdkVersion 26 versionCode 1 versionName "1.0" testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" } buildTypes { release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } } } dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', { exclude group: 'com.android.support', module: 'support-annotations' }) compile 'com.android.support:appcompat-v7:26.+' testCompile 'junit:junit:4.12' }
When I change it to the following:
apply plugin: 'com.android.application' android { compileSdkVersion 26 buildToolsVersion "26.0.0" defaultConfig { applicationId "com.app.test" minSdkVersion 24 targetSdkVersion 26 versionCode 1 versionName "1.0" testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" } buildTypes { release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } } } dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) compile 'com.android.support:appcompat-v7:26.+' testCompile 'junit:junit:4.12' // App dependencies, including test compile 'com.android.support:support-annotations:22.2.0' // Testing-only dependencies androidTestCompile 'com.android.support.test:runner:1.0.0' androidTestCompile 'com.android.support.test.espresso:espresso-core:3.0.0' }
I get the following errors:
Error: (29, 24) Failed to solve: com.android.support.test: runner: 1.0.0
Repository installation and synchronization project
Error: (30, 24) Failed to solve: com.android.support.test.espresso: espresso-core: 3.0.0
Repository installation and synchronization project
I tried to click the link “Install repository and project synchronization”, but nothing happens. I also tried looking at the SDK manager, but I can't see anything.
source share