前几天Android Studio 3.6 稳定版发布,在升级过程中,遇到了一些问题,主要是更新过程中,gradle等资源download失败,大概错误格式都是以下这些
Could not GET 'https://xxxxx/xxxxx.jar
或者
Could not GET 'https://xxxxx/xxxxx.pom
基本上是一些老生常谈的问题, 众所周知国内访问资源的墙
解决这类问题最佳做法当然是找梯子, 除此之外,国内还有一些镜像地址可以使用
Android Studio配置阿里云镜像地址,加速依赖资源下载 这篇博客介绍的非常详细
但是, 文章中的init.gralde文件里面配置的地址已经失效
点击页面提示的超链接,跳转到以下地址,找到对应残酷地址进行替换 https://maven.aliyun.com/mvn/view
重新sync gradle, 能够看到log提示已经将仓库地址替换
下面是我替换好的一份,但不保证时效性, 如有失效请自行替换
allprojects{ repositories { def ALIYUN_REPOSITORY_URL = 'https://maven.aliyun.com/repository/public' def ALIYUN_JCENTER_URL = 'https://maven.aliyun.com/repository/jcenter' all { ArtifactRepository repo -> if(repo instanceof MavenArtifactRepository){ def url = repo.url.toString() if (url.startsWith('https://repo1.maven.org/maven2') || url.startsWith('http://repo1.maven.org/maven2')) { project.logger.lifecycle "Repository ${repo.url} replaced by $ALIYUN_REPOSITORY_URL." remove repo } if (url.startsWith('https://jcenter.bintray.com/') || url.startsWith('http://jcenter.bintray.com/')) { project.logger.lifecycle "Repository ${repo.url} replaced by $ALIYUN_JCENTER_URL." remove repo } } } maven { url ALIYUN_REPOSITORY_URL url ALIYUN_JCENTER_URL } } buildscript{ repositories { def ALIYUN_REPOSITORY_URL = 'https://maven.aliyun.com/repository/public' def ALIYUN_JCENTER_URL = 'https://maven.aliyun.com/repository/jcenter' all { ArtifactRepository repo -> if(repo instanceof MavenArtifactRepository){ def url = repo.url.toString() if (url.startsWith('https://repo1.maven.org/maven2') || url.startsWith('http://repo1.maven.org/maven2')) { project.logger.lifecycle "Repository ${repo.url} replaced by $ALIYUN_REPOSITORY_URL." remove repo } if (url.startsWith('https://jcenter.bintray.com/') || url.startsWith('http://jcenter.bintray.com/')) { project.logger.lifecycle "Repository ${repo.url} replaced by $ALIYUN_JCENTER_URL." remove repo } } } maven { url ALIYUN_REPOSITORY_URL url ALIYUN_JCENTER_URL } } } }