Android Studio sync build.gradle appears: Failed to resolve: com.android.support:appcompat problem

After initializing a project using Android Studio, you need to sync the app/build.gradle file, but it will report an error such as:

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

What is the reason for this?
If your Android SDK is greater than 26.0.0, you will need to add the following statements in build.Gradle in the root directory of your project:

...

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

...

Refer to the link
In addition, if it still doesn’t work, let’s see if the SDK version is correct. In app/build.gradle, there is a column of data that is buildToolsVersion, and we should write its SDK version

Read More: