无法解析 com.android.support.espresso:espresso-core:2.2.2

Noe*_*ton 3 compiler-errors android-studio android-gradle-plugin

我刚刚第一次下载了 android studio,但出现了 gradle 错误。我已经下载了 SDK 提供的所有内容,但仍然出现相同的错误。

apply plugin: 'com.android.application'

android {
compileSdkVersion 25
buildToolsVersion "25.0.2"
defaultConfig {
    applicationId "com.example.noelly.myapplication"
    minSdkVersion 19
    targetSdkVersion 25
    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:25.+'
testCompile 'junit:junit:4.12'
}
Run Code Online (Sandbox Code Playgroud)

我得到的错误是

  (Failed to resolve: com.android.support.appcompat-v7:25.+)
Run Code Online (Sandbox Code Playgroud)

(Failed to resolve: com.android.support.espresso:espresso-core:2.2.2)
Run Code Online (Sandbox Code Playgroud)

顺便说一下,一切都是最新的,请帮助这真是令人沮丧的开始。

**从答案中编辑-安装工具的一张图片--- sdktoolsscreenshot

代码形式项目build.gradle

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
repositories {
    jcenter()
}
dependencies {
    classpath 'com.android.tools.build:gradle:2.2.3'

    // NOTE: Do not place your application dependencies here; they belong
    // in the individual module build.gradle files
}
}

allprojects {
repositories {
    jcenter()
}
}

task clean(type: Delete) {
delete rootProject.buildDir
}
Run Code Online (Sandbox Code Playgroud)

新的错误消息_____ newerrorscreenshot

Nar*_*esh 5

无法解析 com.android.support.espresso:espresso-core:2.2.2

当我们重构布局名称时可能会发生此错误。

我遇到了同样的问题,我的错误是我创建了布局命名test.xml,然后当我使用layout_offers.xml重构该名称时,我的 gradle 被更改为类似


dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    androidTestCompile('com.android.support.detail_layout.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    })
Run Code Online (Sandbox Code Playgroud)

而它应该像跟随

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'
})
Run Code Online (Sandbox Code Playgroud)

因此,一种解决方案是我们应该避免使用test.xml作为布局名称。