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的,希望对出现这个问题的小伙伴有所帮助,如果还是不能解决的话俺也没得办法了(笑哭)。