美文网首页
解决Gradle 依赖下载慢

解决Gradle 依赖下载慢

作者: 黑色海鸥 | 来源:发表于2018-09-16 22:38 被阅读34次

参考

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镜像仓库地址

http://maven.aliyun.com/nexus/content/repositories/jcenter

google镜像仓库地址

http://maven.aliyun.com/nexus/content/repositories/google

完整模式

buildscript {
    repositories {
//        mavenCentral()
//        jcenter()
//        google()
        maven { url 'https://plugins.gradle.org/m2/' }
        maven { url 'http://maven.aliyun.com/nexus/content/repositories/google' }
        maven { url 'http://maven.aliyun.com/nexus/content/groups/public/' }
        maven { url 'http://maven.aliyun.com/nexus/content/repositories/jcenter'}

    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.0.1'
    }
}

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

    }
}

相关文章

网友评论

      本文标题:解决Gradle 依赖下载慢

      本文链接:https://www.haomeiwen.com/subject/lmrqnftx.html