Android Studio3.5.2安装后gradle问题解决过程

Android studio3.5.2搭建第一个程序时出现:

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

解决方案:

第一步 换镜像
这里用到的是阿里镜像
(!!!不是最终版本 ,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

第三步

出现新error

ERROR: SSL peer shut down incorrectly

更改gradle-wrapper.properties中的https为http解决问题
第四步
到这里sync project成功 run的时候再次出现和第一步一样的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找了一天,尝试了各种方法无果。最后查找阿里云镜像的官方文档,直接解决。算是一个教训吧。

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。