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