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

前段時(shí)間自己用的Android Studio的版本不一樣,當(dāng)我的項(xiàng)目在版本高的Android Studio上編譯過之后放到低版本,就出現(xiàn)了題目上的錯(cuò)誤,
解決方法:

方法1.經(jīng)過多次嘗試,發(fā)現(xiàn)只要改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過一段時(shí)候后發(fā)現(xiàn)不好用了,用了這個(gè)博主的方法
,剛開始沒有效果,我之后用了第3個(gè)方法,再重啟AndroidStudio就好了,都可以試試,我覺得是2方法管用。

方法3.博主的原文鏈接

把原有build配置

allprojects {

    repositories {

        jcenter()

        google()

    }

}

改為

allprojects {

    repositories {

        //新加

        mavenCentral()

        jcenter()

        //新加

        mavenLocal()

        google()

    }

}
方法四

降低gradle的版本


出錯(cuò)的版本

更改gradle的版本,打開以前好用的項(xiàng)目就能查看它的gradle版本,之后將自己的版本號(hào)改為跟它相同即可


更改后的版本號(hào)
方法五

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


搜狗截圖20200610103504.png

2.去C:\Users\xxx.gradle\wrapper\dists目錄查看是否包含此版本的gradle的zip(沒有的話去gradle官網(wǎng)下載對應(yīng)的版本)


搜狗截圖20200610103755.png

3.將gradle換成本地的.點(diǎn)擊syncNow


搜狗截圖20200610103924.png
記得及時(shí)的清除緩存重啟
搜狗截圖20200610104037.png
最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容