网上有很多报下面这个错误:
这个错误的解决办法,经常都是莫名出现的,这个问题是由于项目build.gradle中没有配置google()所造成的,一般在buildscript和allprojects的配置项中都加上即可,然而有时还是解决不了问题,有些项目本来就已经加了,或者手动添加了依旧不行,其实这个时候可以试一下,将google()都放到jcenter()之前就可以了,而且allprojects中都不一定要加上,保证buildscript 中有就行了。感觉这个还是网络问题造成的。
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
jcenter()
maven {
url 'https://maven.google.com/'
name 'Google'
}
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.2'
}
}
allprojects {
repositories {
jcenter()
maven {
url 'https://maven.google.com/'
name 'Google'
}
}
}