[英]Failed to resolve: com.android.support.test.espresso
My build.gradle file is below: 我的build.gradle文件如下:
apply plugin: 'com.android.application' 应用插件:“ com.android.application”
android { 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' 排除组:“ com.android.support”,模块:“ 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. 我的问题是Internet连接。 I actually was connected to the Internet when trying to build my project, but I had a very slow connection.
尝试构建项目时,我实际上已连接到Internet,但是连接速度很慢。 Once I had solid wifi, I ran the build again and this issue went away.
有了稳定的wifi后,我再次运行了构建,此问题就消失了。 You also may need to adjust your settings for running online/offline, as Android Studio will tell you.
正如Android Studio会告诉您的那样,您可能还需要调整运行在线/离线设置。 In your project's build.gradle file you should have this maven reference in your repositories:
在项目的build.gradle文件中,您的存储库中应具有以下Maven参考:
repositories {
jcenter()
maven {
url 'https://maven.google.com/'
name 'Google'
}
google() //you may or may not need this line
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.