When connected Android Studio in google and jcenter warehouse, it will be relatively slow and some things will download failed. To solve this problem, you can set up warehouses to Ali cloud storage, as follows:
Manually modify the default configuration repositories
buildscript {
repositories {
google()
jcenter()
mavenCentral()
maven { url'http://maven.aliyun.com/nexus/content/groups/public/'}
maven { url'https://maven.aliyun.com/repository/public/' }
maven { url'https://maven.aliyun.com/repository/google/' }
maven { url'https://maven.aliyun.com/repository/jcenter/' }
maven { url'https://maven.aliyun.com/repository/central/' }
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.0'
}
}
allprojects {
repositories {
google()
jcenter()
mavenCentral()
maven { url "https://oss.sonatype.org/content/repositories/snapshots" }
maven { url'http://maven.aliyun.com/nexus/content/groups/public/'}
maven { url'https://maven.aliyun.com/repository/public/' }
maven { url'https://maven.aliyun.com/repository/google/' }
maven { url'https://maven.aliyun.com/repository/jcenter/' }
maven { url'https://maven.aliyun.com/repository/central/' }
}
}
Or build their own maven PW, is set to build a local warehouse, such as:
maven{
url 'http://....../nexus/content/groups/public/'
}
Permanently modify the default configuration repositories
- In Android Studio installation directory, locate the subdirectory:
\plugins\android\lib\templates\gradle-projects\NewAndroidProject\root
- Modify
build.gradle.ftl
therepositories
node contents of the warehouse address we need to define, modifybuildscript
andallprojects
nodes underrepositories
, as follows:
After editing, restart Android Studio, later when the new project will use the modified template.
Below, this is a new project build.gradle
screenshot: