【Android Studio】显示“unable to find valid certification path to requested target”问题

unable to find valid certification path to requested target问题

前言

        相信很多刚刚开始学习Android的小伙伴在安装好Android Studio之后都遇到了unable to find valid certification path to requested target这一问题。我在刚开始使用AS的时候也同样被这个问题所困扰,每天都会用一两个小时的时间来寻找解决这个问题的方法。然而在尝试了CSDN中的各种方法后还是徒劳无功,这个问题大概的意思是没有访问某个网页的有效证书,但是尝试了导入证书等一系列方法后还是没有效果,最后实在耗不起了就去了淘宝花了40块钱终于给解决了。

解决方案

打开build.gradle文件,将里面的内容修改成如下:

// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
    repositories {
        //位置1 配置
        maven { url 'http://maven.aliyun.com/nexus/content/groups/public/' }
        maven { url 'http://maven.aliyun.com/nexus/content/repositories/jcenter' }
        maven {
            url "https://maven.google.com"
        }
        google()
        jcenter()
        maven { url "https://jitpack.io" }
        mavenCentral()
        jcenter { url "http://jcenter.bintray.com/" }

    }
    dependencies {
        classpath "com.android.tools.build:gradle:4.1.1"

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

allprojects {
    repositories {
        //位置2 配置
        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
}

注:这个文件是每次创建一个项目后都要进行修改的。

注:在淘宝客服远程操作过程中也使用了导入证书,重装jdk的方法但是之后都没有解决问题,最后是把这个文件改了才成功build的,希望对出现这个问题的小伙伴有所帮助,如果还是不能解决的话俺也没得办法了(笑哭)。

评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

小树ぅ

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值