Android studio ERROR: Failed to resolve: androidx.appcompat:appcompat:1.1.0 problem solution

       Today, I imported a project downloaded from github, and reported an error such as ERROR: Failed to resolve: androidx.appcompat:appcompat:1.1.0. From the Internet search for problems, most of the reasons are 1. Change 1.1.0 to 1.0. 2, 2, sdk compileSdkVersion buildToolsVersion problem.

        The error reported by me here is indeed not the reason above, and then I looked at the related API of appcompat and found the reason.

Declare dependencies

To add Appcompat's dependencies, you must add the Google Maven repository to the project. Please read  Google's Maven code base for details.

build.gradle Add the dependencies of the required artifacts to the files of the application or module  :

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"
}

Note: You must add the Google Maven code base to the project, and then try again to compile and pass.

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/'
    }
}

Guess you like

Origin blog.csdn.net/qaz4300321/article/details/109385554