一、前言
第一次创建项目时AS会直接从默认的仓库下载,由于是国外服务器,下载非常慢,有时部分库还无法下载。所以我们需要将默认的仓库地址替换为国内的阿里云镜像地址,从而提升下载速度。
二、步骤
步骤一:
打开【build.gradle】文件。
步骤二:
将repositories标签中的内容替换成自己需要的阿里镜像maven仓库地址。
阿里镜像maven仓库地址对应表请查看附录。
repositories {
maven { url 'https://maven.aliyun.com/repository/central' }
maven { url 'https://maven.aliyun.com/repository/google' }
maven { url 'https://maven.aliyun.com/repository/gradle-plugin' }
maven { url 'https://maven.aliyun.com/repository/jcenter' }
maven { url 'https://maven.aliyun.com/repository/public' }
maven { url 'https://jitpack.io' }
}
三、附录
仓库名称 | 阿里云仓库地址 | 源地址 |
---|---|---|
central | https://maven.aliyun.com/repository/central | https://repo1.maven.org/maven2/ |
jcenter | https://maven.aliyun.com/repository/jcenter | http://jcenter.bintray.com/ |
public | https://maven.aliyun.com/repository/public | central仓和jcenter仓的聚合仓 |
https://maven.aliyun.com/repository/google | https://maven.google.com/ | |
gradle-pluginf | https://maven.aliyun.com/repository/gradle-plugin | https://plugins.gradle.org/m2/ |
spring | https://maven.aliyun.com/repository/spring | http://repo.spring.io/libs-milestone/ |
spring-plugin | https://maven.aliyun.com/repository/spring-plugin | http://repo.spring.io/plugins-release/ |
grails-core | https://maven.aliyun.com/repository/grails-core | https://repo.grails.org/grails/core |
apache snapshots | https://maven.aliyun.com/repository/apache-snapshots | https://repository.apache.org/snapshots/ |