My build.gradle file is below:
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
buildToolsVersion '25.0.3'
defaultConfig {
applicationId "com.xavier.hello"
minSdkVersion 15
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(include: ['*.jar'], dir: 'libs')
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2',
{
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support.constraint:constraint-layout:1.0.2'
testCompile 'junit:junit:4.12'
}
It gives following error every time:
I had the same problem when I wanted to try Espresso.
I've resolved it by adding
maven {
url "https://maven.google.com"
}
to
allprojects {
repositories {
jcenter()
maven {
url "https://maven.google.com"
}
}
}
This can be caused by two different issues:
The problem in my case was Internet connectivity. I actually was connected to the Internet when trying to build my project, but I had a very slow connection. Once I had solid wifi, I ran the build again and this issue went away. You also may need to adjust your settings for running online/offline, as Android Studio will tell you. In your project's build.gradle file you should have this maven reference in your repositories:
repositories {
jcenter()
maven {
url 'https://maven.google.com/'
name 'Google'
}
google() //you may or may not need this line
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.