美文网首页
android studio Gradle下载慢

android studio Gradle下载慢

作者: 星云春风 | 来源:发表于2020-11-29 15:06 被阅读0次

    1.C:\Users\用户.gradle下init.gradle(沒有此文件就新建一個)文件下增加如下代码内容

    allprojects{
        repositories {
            def ALIYUN_REPOSITORY_URL = 'http://maven.aliyun.com/nexus/content/groups/public'
            def ALIYUN_JCENTER_URL = 'http://maven.aliyun.com/nexus/content/repositories/jcenter'
            all { ArtifactRepository repo ->
                if(repo instanceof MavenArtifactRepository){
                    def url = repo.url.toString()
                    if (url.startsWith('https://repo1.maven.org/maven2')) {
                        project.logger.lifecycle "Repository ${repo.url} replaced by $ALIYUN_REPOSITORY_URL."
                        remove repo
                    }
                    if (url.startsWith('https://jcenter.bintray.com/')) {
                        project.logger.lifecycle "Repository ${repo.url} replaced by $ALIYUN_JCENTER_URL."
                        remove repo
                    }
                }
            }
            maven {
                url ALIYUN_REPOSITORY_URL
                url ALIYUN_JCENTER_URL
            }
        }
    }
    
    

    2.android 工程根目录下的的build.gradle文件中配置国内阿里镜像库

    buildscript {
    ......
        repositories {
            maven { url 'http://maven.aliyun.com/repository/google' }
            maven { url 'http://maven.aliyun.com/repository/jcenter' }
            maven { url 'http://maven.aliyun.com/nexus/content/groups/public' }
            maven { url 'http://maven.aliyun.com/nexus/content/repositories/gradle-plugin' }
            google()
            jcenter()
    
        }
    .....
    }
    
    ........
    
    allprojects {
        repositories {
            maven { url 'http://maven.aliyun.com/repository/google' }
            maven { url 'http://maven.aliyun.com/repository/jcenter' }
            maven { url 'http://maven.aliyun.com/nexus/content/groups/public' }
            maven { url 'http://maven.aliyun.com/nexus/content/repositories/gradle-plugin' }
            google()
            jcenter()
    
        }
    }
    

    相关文章

      网友评论

          本文标题:android studio Gradle下载慢

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