在天朝使用jcenter凝化、mavenCentral及google三個(gè)遠(yuǎn)程倉(cāng)庫(kù)厘唾,Gradle Sync會(huì)很慢规脸,goole倉(cāng)庫(kù)甚至需要科學(xué)上網(wǎng)才能訪問(wèn)预麸。為了加快Gradle Sync速度滔驶,一招教你優(yōu)先用 阿里云倉(cāng)庫(kù)服務(wù) 的倉(cāng)庫(kù)作為下載源夜郁。
Maven倉(cāng)庫(kù)列表
倉(cāng)庫(kù)名 | 簡(jiǎn)介 | 實(shí)際地址 | 使用地址 |
---|---|---|---|
jcenter | JFrog公司提供的倉(cāng)庫(kù) | http://jcenter.bintray.com | https://maven.aliyun.com/repository/jcenter |
https://maven.aliyun.com/nexus/content/repositories/jcenter | |||
mavenLocal | 本臺(tái)電腦上的倉(cāng)庫(kù) | {USER_HOME}/.m2/repository | C:/Users/liyujiang/.m2/repository (Windows) |
/home/liyujiang/.m2/repository (Linux) | |||
mavenCentral | Sonatype公司提供的中央庫(kù) | http://central.maven.org/maven2 | https://maven.aliyun.com/repository/central |
https://maven.aliyun.com/nexus/content/repositories/central | |||
Google公司提供的倉(cāng)庫(kù) | https://maven.google.com | https://maven.aliyun.com/repository/google |
https://maven.aliyun.com/nexus/content/repositories/google
https://dl.google.com/dl/android/maven2 |
| jitpack | JitPack提供的倉(cāng)庫(kù) | https://jitpack.io | https://jitpack.io |
| public | jcenter和mavenCentral的聚合倉(cāng)庫(kù) | https://maven.aliyun.com/repository/public
https://maven.aliyun.com/nexus/content/groups/public |
| gradle-plugin | Gradle插件倉(cāng)庫(kù) | https://plugins.gradle.org/m2 | https://maven.aliyun.com/repository/gradle-plugin
https://maven.aliyun.com/nexus/content/repositories/gradle-plugin |
阿里云代理倉(cāng)庫(kù)配置
在項(xiàng)目根目錄下的build.gradle
的buildscript.repositories
及allprojects.repositories
閉包內(nèi)的最前面(Gradle是從上往下尋找的什燕,故要放到j(luò)center()及google()的前面),添加阿里云倉(cāng)庫(kù)服務(wù)的代理倉(cāng)庫(kù)地址竞端,示例如下:
buildscript {
repositories {
maven {
url 'https://maven.aliyun.com/repository/jcenter'
}
maven {
url 'https://maven.aliyun.com/repository/google'
}
jcenter()
google()
}
}
allprojects {
repositories {
maven {
url 'https://maven.aliyun.com/repository/jcenter'
}
maven {
url 'https://maven.aliyun.com/repository/central'
}
maven {
url 'https://maven.aliyun.com/repository/google'
}
jcenter()
mavenCentral()
google()
}
}