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全局配置国内镜像

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容