解决gradle依赖库下载慢的方法

工程的gradle文件里面google官方的依赖方式:
buildscript {
    repositories {
        mavenCentral()
        jcenter()
        google()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.0.1'
    }
}
 
allprojects {
    repositories {
        mavenCentral()
        jcenter()
        google()
    }
}

上面的这种方式,由于会用到google的maven仓库,直接导致相关的依赖库无法下载
那我们的解决方式是使用阿里云的国内镜像

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

我们更新工程的build.gradle形式如下:

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依赖库下载慢的方法)