Android studio default project fails: Error:Failed to resolve: com.android.support:support-v4:25.2.0

Android studio default project fails: Error:Failed to resolve: com.android.support:support-v4:25.2.0

我真的是第一次开始应用程序开发,创建新项目时的默认项目不会构建。我已经尝试在 Google 和 SO 上寻找这些错误并找到了一些但他们的解决方案不起作用。鉴于我根本没有编辑文件,我认为这是 Android Studio 未正确设置但无法弄清楚的问题。错误如下:

Error:Failed to resolve: com.android.support:support-v4:25.2.0
Install Repository and sync project
Open File
Show in Project Structure dialog

Error:(23, 24) Failed to resolve: com.android.support.test.espresso:espresso-core:2.2.2
Install Repository and sync project
Show in File
Show in Project Structure dialog

Error:(26, 13) Failed to resolve: com.android.support:appcompat-v7:26.+
Install Repository and sync project
Show in File
Show in Project Structure dialog

它指向的build.gradle文件如下:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 26
    buildToolsVersion "26.0.0"
    defaultConfig {
        applicationId "com.extremecomputing.spotzz"
        minSdkVersion 17
        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.google.android.gms:play-services-maps:11.0.1'
    testCompile 'junit:junit:4.12'
}

我已经尝试过之前的一个项目,我创建了一些我在网上找到的东西。例如他们在版本中推荐的 + 可能会导致不可预测的构建,但事实并非如此。有人在 dependencies 部分推荐了一些编译行,它暂时改变了错误说我需要下载一些东西,然后我做了然后又回到了原来的错误。我还尝试确保 SDK 工具已更新,而且看起来确实如此。任何建议将不胜感激。

试试这个:

  1. 在 Android Studio 中,打开工具 -> Android -> SDK 管理器
  2. 在选项卡 "SDK Tools" 下取消检查导致问题的库
  3. 单击 "apply" 卸载它们
  4. 重新检查相同的库单击 "apply" 重新安装它们
  5. 关闭 SDK 管理器和 运行 Gradle 同步/构建

请注意 revision 25.4.0 to the latest, we need to add google maven. As in the release note says 的支持库:

Important: The support libraries are now available through Google's Maven repository. You do not need to download the support repository from the SDK Manager. For more information, see Support Library Setup.

因此您需要将 google maven 添加到您的 root build.gradle,如下所示:

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

Support Library Setup 阅读更多内容。

我遇到了同样的问题,这是由于另一个库的干扰。
就我而言,我不得不发表评论:

编译'com.onesignal:OneSignal:[3.5.3,4.0.0)

现在构建