- A+
所属分类:android
这是因为gradle sync时部分网址被墙的原因,一些资源无法下载,推荐使用阿里源去解决这样的问题。
在当前用户主目录的.gradle目录下,新建init.gradle文件,内容如下
allprojects { repositories { maven { url 'https://maven.aliyun.com/repository/public/' } maven { url 'https://maven.aliyun.com/repository/google/' } all { ArtifactRepository repo -> if (repo instanceof MavenArtifactRepository) { def url = repo.url.toString() if (url.startsWith('https://repo.maven.apache.org/maven2/') || url.startsWith('https://repo.maven.org/maven2') || url.startsWith('https://repo1.maven.org/maven2') || url.startsWith('https://jcenter.bintray.com/') || url.startsWith('https://maven.google.com/') || url.startsWith('https://dl.google.com/dl/android/maven2/')) { //project.logger.lifecycle "Repository ${repo.url} replaced by $REPOSITORY_URL." remove repo } } } } buildscript { repositories { maven{ url 'https://maven.aliyun.com/repository/public/'} maven{ url 'https://maven.aliyun.com/repository/google/'} all { ArtifactRepository repo -> if (repo instanceof MavenArtifactRepository) { def url = repo.url.toString() if (url.startsWith('https://repo1.maven.org/maven2') || url.startsWith('https://jcenter.bintray.com/') || url.startsWith('https://dl.google.com/dl/android/maven2/')) { //project.logger.lifecycle "Repository ${repo.url} replaced by $REPOSITORY_URL." remove repo } } } } } }