ERROR: Cause: unable to find valid certification path to requested target

前段时间自己用的Android Studio的版本不一样,当我的项目在版本高的Android Studio上编译过之后放到低版本,就出现了题目上的错误,
解决方法:

方法1.经过多次尝试,发现只要改gradle下面的builde.gradle就可以了

之前是这样

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 {
        google()
        jcenter()
        
    }
}

将maven改为阿里云的就可以了,改过之后

buildscript {
    repositories {
        maven{ url 'http://maven.aliyun.com/nexus/content/groups/public/'}
        google()
        
    }
    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 'http://maven.aliyun.com/nexus/content/groups/public/'}
        google()
        
    }
}
方法2

用了方法1过一段时候后发现不好用了,用了这个博主的方法
,刚开始没有效果,我之后用了第3个方法,再重启AndroidStudio就好了,都可以试试,我觉得是2方法管用。

方法3.博主的原文链接

把原有build配置

allprojects {

    repositories {

        jcenter()

        google()

    }

}

改为

allprojects {

    repositories {

        //新加

        mavenCentral()

        jcenter()

        //新加

        mavenLocal()

        google()

    }

}
方法四

降低gradle的版本


ERROR: Cause: unable to find valid certification path to requested target_第1张图片
出错的版本

更改gradle的版本,打开以前好用的项目就能查看它的gradle版本,之后将自己的版本号改为跟它相同即可


ERROR: Cause: unable to find valid certification path to requested target_第2张图片
更改后的版本号
方法五

使用本地的gradle
1.查看工程的gradle版本


ERROR: Cause: unable to find valid certification path to requested target_第3张图片
搜狗截图20200610103504.png

2.去C:\Users\xxx.gradle\wrapper\dists目录查看是否包含此版本的gradle的zip(没有的话去gradle官网下载对应的版本)


ERROR: Cause: unable to find valid certification path to requested target_第4张图片
搜狗截图20200610103755.png

3.将gradle换成本地的.点击syncNow


ERROR: Cause: unable to find valid certification path to requested target_第5张图片
搜狗截图20200610103924.png
记得及时的清除缓存重启
ERROR: Cause: unable to find valid certification path to requested target_第6张图片
搜狗截图20200610104037.png

你可能感兴趣的:(ERROR: Cause: unable to find valid certification path to requested target)