解决Gradle 依赖下载慢

参考

阿里云公共代理库
https://www.jianshu.com/p/ab1f5e5f5f5c

修改前的依赖

buildscript {
    repositories {
        mavenCentral()
        jcenter()
        google()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.0.1'
    }
}

allprojects {
    repositories {
        mavenCentral()
        jcenter()
        google()
    }
}

上面的这种方式,由于会用到google的maven仓库,直接导致相关的依赖库无法下载,gradle plug3.0无法下载的问题。

用阿里云仓库解决问题

mavenCentral镜像仓库地址

http://maven.aliyun.com/nexus/content/groups/public/

jentral镜像仓库地址

https://maven.aliyun.com/repository/jcenter

google镜像仓库地址

https://maven.aliyun.com/repository/google

完整模式

buildscript {
    repositories {
//        mavenCentral()
//        jcenter()
//        google()
          maven { url 'https://maven.aliyun.com/repository/gradle-plugin' }
          maven { url 'https://maven.aliyun.com/repository/google' }
          maven { url 'http://maven.aliyun.com/nexus/content/groups/public/' }
          maven { url 'https://maven.aliyun.com/repository/jcenter'}
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.0.1'
    }
}

allprojects {
    repositories {
//        mavenCentral()
//        jcenter()
//        google()
        maven { url 'https://maven.aliyun.com/repository/gradle-plugin' }
        maven { url 'https://maven.aliyun.com/repository/google' }
        maven { url 'http://maven.aliyun.com/nexus/content/groups/public/' }
        maven { url 'https://maven.aliyun.com/repository/jcenter'}

    }
}

你可能感兴趣的:(解决Gradle 依赖下载慢)