Android studio ERROR: Failed to resolve: androidx.appcompat:appcompat:1.1.0 问题解决方法

       今天导入从github上下载的一个项目,报了ERROR: Failed to resolve: androidx.appcompat:appcompat:1.1.0 这样一个错误,从网上搜问题,大部分原因是1、将1.1.0改为1.0.2,2、sdk compileSdkVersion  buildToolsVersion问题。

        我这边的报错确不是以上原因,然后看下appcompat的相关api,才找到了原因

声明依赖项

要添加 Appcompat 的依赖项,您必须将 Google Maven 代码库添加到项目中。请阅读 Google 的 Maven 代码库了解详情。

在应用或模块的 build.gradle 文件中添加所需工件的依赖项:

dependencies {
    def appcompat_version = "1.2.0"

    implementation "androidx.appcompat:appcompat:$appcompat_version"
    // For loading and tinting drawables on older versions of the platform
    implementation "androidx.appcompat:appcompat-resources:$appcompat_version"
}

注意:必须将Google Maven 代码库添加到项目中,然后try again,编译通过。

allprojects {
    repositories {
        google()

        // If you're using a version of Gradle lower than 4.1, you must instead use:
        // maven {
        //     url 'https://maven.google.com'
        // }
        // An alternative URL is 'https://dl.google.com/dl/android/maven2/'
    }
}

猜你喜欢

转载自blog.csdn.net/qaz4300321/article/details/109385554