android的报错提示:

Could not find com.android.tools.build:gradle:4.2.2.
Searched in the following locations:
  - https://jcenter.bintray.com/com/android/tools/build/gradle/4.2.2/gradle-4.2.2.pom
If the artifact you are trying to retrieve can be found in the repository but without metadata in 'Maven POM' format, you need to adjust the 'metadataSources { .

解决,在Project的build.gradle中加上“google()”,看图:

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

buildscript {
    repositories {
        jcenter()
        google()//加上这一句
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:4.2.2'

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

allprojects {
    repositories {
        jcenter()
        google()//同上
    }
}

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

更多推荐