Android Studio中的unable to find valid certification path to requested target问题

安装Android studio 3.5.3遇到了gradle的同步问题unable to find valid certification path to requested target。解决方法如下:

1. 进入项目级的build.gradle文件中,将其中的配置改为:

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

buildscript {
    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.5.3'
        
        // 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/google' }
        maven { url 'https://maven.aliyun.com/repository/jcenter' }
        mavenLocal()
        mavenCentral()
    }
}

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

这一步是为了利用阿里的镜像进行加速,提高gradle同步的下载速度。

2. 用谷歌浏览器进入阿里云仓库服务,按下面图片的步骤保存网站的证书。

在这里插入图片描述
点击网址坐标的标识,点击证书。
Android Studio中的unable to find valid certification path to requested target问题_第1张图片
点击复制到文件把证书保存到本地

3. 在android studio中通过setting找到下图的设置选项

Android Studio中的unable to find valid certification path to requested target问题_第2张图片
点击图中加号把刚刚的证书添加进来
Android Studio中的unable to find valid certification path to requested target问题_第3张图片
点击使缓存失效并重启
Android Studio中的unable to find valid certification path to requested target问题_第4张图片
重启后重新同步

4. 等待同步完成后即可启动程序。

你可能感兴趣的:(android)