Skip to content

Android Studio Gradle 下载速度慢解决方法

gradle下载的时候很慢,要等很久。

我们可以使用阿里云的源。不使用jcenter。

修改buildscript的repositories和allprojects中的repositories即可。

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    ext.kotlin_version = '1.3.31'

    repositories {
        maven { url 'http://maven.aliyun.com/nexus/content/groups/public/' }
        google()
//        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.4.2'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
    }
}

allprojects {
    repositories {
        google()
//        jcenter()
        maven { url 'http://maven.aliyun.com/nexus/content/groups/public/' }
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

更换后,下载速度快很多。