美文网首页
gradle切换为阿里云镜像

gradle切换为阿里云镜像

作者: jeffrey_hjf | 来源:发表于2021-08-07 21:02 被阅读0次

    build.gradle 默认的仓库为

    buildscript {
     。。。。。。。
        repositories {
            google()
            jcenter()
        }
    
    。。。。。。。
    }
    

    使用起来非常不便。于是将源换成阿里云的源,
    打开 https://maven.aliyun.com,会转到https://maven.aliyun.com/mvn/view
    选择几个加入到配置文件就可以。

    buildscript {
       。。。。。。。
        repositories {
            maven { url 'https://maven.aliyun.com/repository/jcenter' }
            maven { url 'https://maven.aliyun.com/repository/google' }
            maven { url 'https://maven.aliyun.com/repository/central' }
            maven { url 'https://maven.aliyun.com/repository/gradle-plugin' }
        }
    
        dependencies {
            classpath 'com.android.tools.build:gradle:3.2.1'
            classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
        }
    }
    
    allprojects {
        repositories {
            maven { url 'https://maven.aliyun.com/repository/jcenter' }
            maven { url 'https://maven.aliyun.com/repository/google' }
            maven { url 'https://maven.aliyun.com/repository/central' }
            maven { url 'https://maven.aliyun.com/repository/gradle-plugin' }
        }
    }
    

    如有Flutter,找到flutter安装目录下的 packages\flutter_tools\gradle\flutter.gradle

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

    修改为:

    buildscript {
        repositories {
            maven { url 'https://maven.aliyun.com/repository/jcenter' }
            maven { url 'https://maven.aliyun.com/repository/google' }
            maven { url 'https://maven.aliyun.com/repository/central' }
            maven { url 'https://maven.aliyun.com/repository/gradle-plugin' }
        }
        dependencies {
            classpath 'com.android.tools.build:gradle:3.5.2'
        }
    }
    

    相关文章

      网友评论

          本文标题:gradle切换为阿里云镜像

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