简体   繁体   English

无法解决:com.android.support.test.espresso

[英]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: 这可能是由两个不同的问题引起的:

  1. A problem with your gradle file(s). 您的gradle文件有问题。
  2. Internet connectivity 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.

相关问题 无法解决:com.android.support.test.espresso:espresso-core:3.0.1使用Android Studio 3.0.1 - Failed to resolve: com.android.support.test.espresso:espresso-core:3.0.1 Using Android Studio 3.0.1 无法解决:com.android.support.test.espresso:espresso-core:2.3.3 - Failed to resolve: com.android.support.test.espresso:espresso-core:2.3.3 无法解决:com.android.support.test.espresso:espresso-intents:27.0.2 - Failed to resolve: com.android.support.test.espresso:espresso-intents:27.0.2 无法解析com.android.support.test:runner:1.0.0和'com.android.support.test.espresso:espresso-core:3.0.0' - Failed to resolve com.android.support.test:runner:1.0.0 and 'com.android.support.test.espresso:espresso-core:3.0.0' 无法解析com.android.support.test.espresso:espressgit so-core:3.0.1 - Could not resolve com.android.support.test.espresso:espressgit so-core:3.0.1 无法解决:com.android.support.customtabs - Failed to Resolve: com.android.support.customtabs 无法解决:com.android.support.test:testing-support-lib:0.1 - Failed to resolve: com.android.support.test:testing-support-lib:0.1 无法解析:com.android.support:support-v4:23.0.0 - Failed to resolve: com.android.support:support-v4:23.0.0 无法解决:com.android.support:support-compat:27.2.0 - Failed to resolve: com.android.support:support-compat:27.2.0 无法解析com.android.support:support-v4:23.2.1 - failed to resolve com.android.support:support-v4:23.2.1
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM