When Android Studio to modify the default configuration repositories of new construction

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

  1. In Android Studio installation directory, locate the subdirectory:
\plugins\android\lib\templates\gradle-projects\NewAndroidProject\root

Here Insert Picture Description

  1. Modify build.gradle.ftlthe repositoriesnode contents of the warehouse address we need to define, modify buildscriptand allprojectsnodes under repositories, as follows:
    Here Insert Picture Description

After editing, restart Android Studio, later when the new project will use the modified template.
Below, this is a new project build.gradlescreenshot:
Here Insert Picture Description

Published 18 original articles · won praise 1 · views 768

Guess you like

Origin blog.csdn.net/aha_jasper/article/details/104925248