Gradle下载速度慢解决方案-使用国内镜像进行加速

8,150 阅读1分钟

Gradle下载速度慢解决方案-使用国内镜像进行加速

  1. 打开工程文件根目录 build.gradle
  2. 在 buildscript 和 allprojects 的 repositories 中分别注释掉 jcenter(),并使用国内镜像进行替换:maven{url 'maven.aliyun.com/nexus/conte…
  3. 在 buildscript 的 repositories 添加:maven{url "jitpack.io"}
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
    ext {
        kotlin_version = '1.3.72'
    }
    repositories {
        maven{url 'http://maven.aliyun.com/nexus/content/groups/public/'}
        maven{url "https://jitpack.io"}
        google()
//        jcenter()
    }
    dependencies {
        classpath "com.android.tools.build:gradle:4.0.1"
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

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

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