Android Studio无法解析Espresso 3.0.0 [英] Android Studio can't resolve Espresso 3.0.0

查看:137
本文介绍了Android Studio无法解析Espresso 3.0.0的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

根据 Android Espresso文档迄今为止:

添加Espresso依赖项

要将Espresso依赖项添加到您的项目中,请完成以下步骤:

To add Espresso dependencies to your project, complete the following steps:

  1. 打开您应用的build.gradle文件.通常,这不是顶级build.gradle文件,而是app/build.gradle.
  2. 在依赖项中添加以下行:

androidTestCompile 'com.android.support.test.espresso:espresso-core:3.0.0'
androidTestCompile 'com.android.support.test:runner:1.0.0'

我创建了一个新项目,生成的app/gradle文件是这样的:

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'
}

我收到以下错误:

错误:(29,24)无法解决:com.android.support.test:runner:1.0.0
安装存储库并同步项目
错误:(30,24)无法解决:com.android.support.test.espresso:espresso-core:3.0.0
安装存储库并同步项目

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 project

我尝试单击安装存储库并同步项目",链接,但没有任何反应.我也尝试过浏览SDK管理器,但看不到任何东西.

I 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.

推荐答案

由于评论中的解决方案正在解决问题,因此我将其添加为其他人的答案:

As the solution from comment is solving the problem I am adding it as an answer for others:

请确保添加 Google的行家链接到主build.gradle文件:

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

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

这篇关于Android Studio无法解析Espresso 3.0.0的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆