1、点击File–> setting–>Tools–>Diff&Merge–>Server Certificates
看到Accept non-trusted certificates automatically打钩,如图
2、在build.gradle增加下面代码
maven { url 'https://jitpack.io' }
maven { url 'https://maven.aliyun.com/repository/public' }
maven { url 'https://maven.aliyun.com/repository/google' }
maven { url 'https://maven.aliyun.com/repository/jcenter' }
例子:
buildscript {
repositories {
maven { url 'https://jitpack.io' }
maven { url 'https://maven.aliyun.com/repository/public' }
maven { url 'https://maven.aliyun.com/repository/google' }
maven { url 'https://maven.aliyun.com/repository/jcenter' }
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.4.2'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
maven { url 'https://jitpack.io' }
maven { url 'https://maven.aliyun.com/repository/public' }
maven { url 'https://maven.aliyun.com/repository/google' }
maven { url 'https://maven.aliyun.com/repository/jcenter' }
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
之后一直点击(如图),同步Grade,多使几遍就可以了,一定要坚持住
成功了之后再创建项目就不需要上面操作了