Android Studio Gradle项目同步 - 无法解析Espresso-Core和Appcompat

Oli*_*les 4 android android-support-library android-gradle-plugin

我正在关注https://developer.android.com/training/basics/firstapp/index.html上的"First App"教程.但是,在创建默认的"空活动"项目并尝试构建它时,我收到以下错误:

  • 错误:(23,24)无法解决:com.android.support.test:espresso-core:2.2.2
  • 错误:(26,13)无法解决:com.android.support:appcompat-v7:26.+

我的(默认/自动生成)build.gradle:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 26
    buildToolsVersion "26.0.0"
    defaultConfig {
        applicationId "com.example.myfirstapp"
        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(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.+'
    compile 'com.android.support.constraint:constraint-layout:1.0.2'
    testCompile 'junit:junit:4.12'
}
Run Code Online (Sandbox Code Playgroud)

虽然我已经查看了几个相关的Stack Overflow问题,但我还没有找到一个有效的解决方案.我正在使用Android Studio 2.3.3的全新默认安装.

Gab*_*tti 5

你应该检查你是否repository包括新的谷歌maven回购.
就像是:

allprojects {
    repositories {
        jcenter()
        maven {
            url "https://maven.google.com"
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

有关详细信息,请参阅文档