AndroidX ERROR: Failed to resolve: appcompat

AndroidX ERROR: Failed to resolve: appcompat

当我创建一个新项目时,我默认有这些依赖项:

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'androidx.appcompat:appcompat:1.1.0'
    implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'androidx.test.ext:junit:1.1.0'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
}

一开始同步项目失败,我无法修复。错误是 'androidx.appcompat:appcompat:1.1.0' gradle 无法解析此依赖项。

错误日志:

ERROR: Failed to resolve: appcompat
Affected Modules: app

Gradle 模块项目:

buildscript {
    repositories {
        google()
        jcenter()

    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.5.2'
    }
}

allprojects {
    repositories {
        google()
        jcenter()
    }
}

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

我检查了下载 URL 结果是 404 : https://dl.google.com/dl/android/maven2/androidx/appcompat/appcompat/1.1.0

知道如何解决吗?

试试这个:-

实施'androidx.appcompat:appcompat:1.1.0'

实施"androidx.core:core-ktx:1.1.0"

令人惊讶的是,删除 Gradle 主页 (.gradle) 问题已解决。可能是损坏的缓存或其他原因造成了错误。