AndroidStudio出现Error:Cause: unable to find valid certification path to requested target的解决方法

1、点击File–> setting–>Tools–>Diff&Merge–>Server Certificates
看到Accept non-trusted certificates automatically打钩,如图
AndroidStudio出现Error:Cause: unable to find valid certification path to requested target的解决方法_第1张图片
2、在build.gradle增加下面代码

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://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://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,多使几遍就可以了,一定要坚持住
在这里插入图片描述

成功了之后再创建项目就不需要上面操作了

你可能感兴趣的:(Android)