前幾天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 } } } }