[Android] 编译工程时maven报错

现象

编译工程时,编译log中报出因为SSL证书等原因无法下载下面仓库中的依赖:

1. https://jcenter.bintray.com
2. https://dl.google.com
3. https://dl.google.com/dl/android/maven2

导致编译失败。
常见的SSL异常有:

> Could not download xxxxxx.jar (xxx.xxx.xxx:xxx:x.x.x)
      > Could not get resource 'https://jcenter.bintray.com/xxx.xxx/xxx/x.x.x/x.x.x-x.x.x.jar'.
         > Could not GET 'https://jcenter.bintray.com/xxx.xxx/xxx/x.x.x/x.x.x-x.x.x.jar'.
            > Unexpected error: java.security.InvalidAlgorithmParameterException: the trustAnchors parameter must be non-empty

解决

  1. 找到工程的根build.gradle脚本
  2. 使用以下阿里云maven仓库代替repositories节点中原有的maven()jcenter()google()
    maven { url'[https://maven.aliyun.com/nexus/content/groups/public/](javascript:void(0);)'}
    maven { url'[https://maven.aliyun.com/repository/public/](javascript:void(0);)' }
    maven { url'[https://maven.aliyun.com/repository/google/](javascript:void(0);)' }
    maven { url'[https://maven.aliyun.com/repository/jcenter/](javascript:void(0);)' }
    maven { url'[https://maven.aliyun.com/repository/central/](javascript:void(0);)' }
    
  3. 重新sync工程

你可能感兴趣的:([Android] 编译工程时maven报错)