Android Studio3.5.2安裝后gradle問題解決過程

Android studio3.5.2搭建第一個程序時出現(xiàn):

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

解決方案:

第一步 換鏡像
這里用到的是阿里鏡像
(!?。〔皇亲罱K版本 ,build.gradle配置用第四步的)

//        google()
//        jcenter()
        maven { url 'https://maven.aliyun.com/repository/google' }
        maven{ url 'https://maven.aliyun.com/repository/jcenter'}

第二步 配置證書

  1. https://blog.csdn.net/qq_17827627/article/details/99404177
    此方法最方便
    注意:上方“Accept non-trusted ceritificates automatically”(自動接受不受信任的證書)要勾選
    證書配置后效果
  2. 該博客提供另一種配置證書方法
    https://blog.csdn.net/frankcheng5143/article/details/52164939

第三步

出現(xiàn)新error

ERROR: SSL peer shut down incorrectly

更改gradle-wrapper.properties中的https為http解決問題
第四步
到這里sync project成功 run的時候再次出現(xiàn)和第一步一樣的error

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

將build.gradle配置改為如下代碼解決:

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

第四步的問題baidu google找了一天,嘗試了各種方法無果。最后查找阿里云鏡像的官方文檔,直接解決。算是一個教訓(xùn)吧。

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

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