未能解决:com.android.support:design:26.2.0 在 Android Studio 中的错误

Failed to resolve: com.android.support:design:26.2.0 error in Android Studio

我正在尝试学习教程,它要求我们从 GitHub 克隆一个项目。我已经这样做了,但是当它在我的 Android Studio 中运行时,出现两个错误,

failed to resolve 'com.android.support:design:26.2.0'
failed to resolve 'com.android.support:appcompat-v7:26.2.0'

我在 Whosebug 上查了一下,这似乎是一个常见问题,但我似乎无法让它工作。

我当前的 gradle 文件如下所示,

模块gradle文件,

apply plugin: 'com.android.application'

android {
    compileSdkVersion 25
    buildToolsVersion "25.0.2"
    defaultConfig {
        applicationId "com.example.android.emojify"
        minSdkVersion 15
        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:design:25.2.0'
    compile 'com.android.support:appcompat-v7:25.2.0'
    testCompile 'junit:junit:4.12'
}

我知道 sdkVersion 需要更改,因为它说不能低于 26,但我已重置为最初从 github.

导入的版本

项目gradle,

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

buildscript {
    repositories {

        google()
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.2.0'

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

allprojects {
    repositories {
        google()
        jcenter()

    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

当我将 sdk 等更改为 26 时出现错误,

Failed to resolve: com.android.support:design:26.2.0

Failed to resolve: com.android.support:appcompat-v7:26.2.0

我在此处阅读了有关添加的内容,

maven {
    url "www.maven.google.com"
}

This doesn't seem to make any difference though.

Failed to resolve: com.android.support:design:26.2.0

Failed to resolve: com.android.support:appcompat-v7:26.2.0

只是因为支持库26的最新版本是26.1.0版本。您最好使用支持库版本 28.0.0 或升级到 AndroidX。