Android Studio can't resolve Espresso 3.0.0
Solution 1
As the solution from comment is solving the problem I am adding it as an answer for others:
Be sure to add Google's maven link to main build.gradle
file:
allprojects {
repositories {
jcenter()
maven {
url "https://maven.google.com"
}
}
}
Solution 2
Simply,
Adding google()
into allprojects > repositories
will do the trick here...
allprojects {
repositories {
google()
jcenter()
}
}
Solution 3
you can downgrade the version, somehow sometimes the targeted version is unavailable from the repo. use IDE-UI to select the latest version:
- Right click on your project folder, select
Open Module Settings
- search for the package you want in the dependencies, for example
This way, you'll never get an un available version
(of course remember to set proper repo in build.gradle
, too)
Comments
-
Quintin Balsdon over 1 year
According to the Android Espresso documentation to date:
Add Espresso dependencies
To add Espresso dependencies to your project, complete the following steps:
- Open your app’s build.gradle file. This is usually not the top-level build.gradle file but app/build.gradle.
- Add the following lines inside 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 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's 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 resolve: com.android.support.test:runner:1.0.0
Install Repository and sync project
Error:(30, 24) Failed to resolve: com.android.support.test.espresso:espresso-core:3.0.0
Install Repository and sync projectI have tried clicking on the "Install repository and sync project" link but nothing happens. I have also tried looking through the SDK manager, but I can't really see anything.