Android Studio cannot resolve Espresso 3.0.0

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.

+5
source share
4 answers

Since the solution from the comment solves the problem, I am adding it as an answer for others:

Be sure to add the Google maven link to the main build.gradle file:

 allprojects { repositories { jcenter() maven { url "https://maven.google.com" } } } 
+12
source

Just,
Adding google() to allprojects > repositories will do the trick here ...

 allprojects { repositories { google() jcenter() } } 
+1
source

use these versions

 androidTestCompile 'com.android.support.test:runner:0.5' androidTestCompile 'com.android.support.test:rules:0.5' androidTestCompile 'com.android.support.test.espresso:espresso-core:2.2.2' 
0
source

You can downgrade, sometimes the target version is not available in the repository. use the IDE-UI to select the latest version:

  1. Right click on your project folder, select Open Module Settings
  2. look for the package you want in the dependencies e.g. enter image description here

This way you will never get an unavailable version (of course, remember to install the correct repo in build.gradle )

0
source

Source: https://habr.com/ru/post/1270478/


All Articles