androidstudio source into Ali cloud (reprint)

Andrews usually slower to compile the project, one of the reasons is to download the package depend on resources more slowly. To solve this problem, you can configure Ali cloud images, speed up the download.

Configuration:

1. The entry into force of specific projects, in the project build.gradle content

 1 buildscript {
 2     repositories {
 3         maven { url 'http://maven.aliyun.com/nexus/content/groups/public/' }
 4         maven { url 'http://maven.aliyun.com/nexus/content/repositories/jcenter' }
 5         maven { url 'http://maven.aliyun.com/nexus/content/repositories/google' }
 6         maven { url 'http://maven.aliyun.com/nexus/content/repositories/gradle-plugin' }
 7     }
 8     dependencies {
 9         classpath 'com.android.tools.build:gradle:3.2.1'
10     }
11 }
12  
13 allprojects {
14     repositories {
15         maven { url 'http://maven.aliyun.com/nexus/content/groups/public/' }
16         maven { url 'http://maven.aliyun.com/nexus/content/repositories/jcenter' }
17         maven { url 'http://maven.aliyun.com/nexus/content/repositories/google' }
18         maven { url 'http://maven.aliyun.com/nexus/content/repositories/gradle-plugin' }
19     }
20 }

2. take effect for all projects

In the user /.gradle/ create init.gradle next file, as follows:

allprojects{
    repositories {
        def ALIYUN_REPOSITORY_URL = 'http://maven.aliyun.com/nexus/content/groups/public'
        def ALIYUN_JCENTER_URL = 'http://maven.aliyun.com/nexus/content/repositories/jcenter'
        all { ArtifactRepository repo ->
            if(repo instanceof MavenArtifactRepository){
                def url = repo.url.toString()
                if (url.startsWith('https://repo1.maven.org/maven2')) {
                    project.logger.lifecycle "Repository ${repo.url} replaced by $ALIYUN_REPOSITORY_URL."
                    remove repo
                }
                if (url.startsWith('https://jcenter.bintray.com/')) {
                    project.logger.lifecycle "Repository ${repo.url} replaced by $ALIYUN_JCENTER_URL."
                    remove repo
                }
            }
        }
        maven {
                url ALIYUN_REPOSITORY_URL
            url ALIYUN_JCENTER_URL
        }
    }
}

 

Guess you like

Origin www.cnblogs.com/qianmaoliugou/p/12369654.html