Gradle Repositories 换用阿里云镜像

Gradle 项目(尤其是 Android 项目)常常要从 Google、Maven Central 下载依赖,但是在大陆下载的速度超级之慢(大约 170kB/s),遇到包大一点的依赖只能干等。

以 Android 为例,定义这些下载源的位置在这里:

 build.gradle

allprojects {

  repositories {

    mavenCentral()

    google()

  }

}

替换成阿里云的依赖就是将这些源替换掉。

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

buildscript{

    // kotlin 版本

    ext.kotlin_version = 1.4.31

    // anko 版本

    ext.anko_version= 0.10.2

    repositories{

        maven{ url https://maven.aliyun.com/repository/google }

        maven{ url https://maven.aliyun.com/repository/public/ }

}

    dependencies{

        classpath com.android.tools.build:gradle:4.1.3

        classpath”org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version”

    }

}

allprojects{

    repositories{

        maven{ url https://maven.aliyun.com/repository/google }

        maven{ url https://maven.aliyun.com/repository/public/ }

        maven{ url”https://jitpack.io” }

}

}

task clean(type: Delete){

    deleterootProject.buildDir

}

// Define versions in a single place

ext{

    // Support library and architecture components support minSdk 19 and above.

    minSdkVersion =21

    targetSdkVersion =28

    compileSdkVersion =28

    buildToolsVersion = 28.0.3

    // App dependencies

    supportLibraryVersion = 28.0.0

    junitVersion = 4.12

    roomVersion =”1.1.1″

}

引用

Where is Gradle folder in Windows

Gradle全局配置国内镜像

© 版权声明

相关文章

暂无评论

none
暂无评论...