解决android studio国内开发者Gradle下载慢问题

   日期:2020-07-10     浏览:87    评论:0    
核心提示:1.C:\\Users\\用户.gradle下gradle.properties文件下增加如下代码内容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_and

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()

    }
}
 
打赏
 本文转载自:网络 
所有权利归属于原作者,如文章来源标示错误或侵犯了您的权利请联系微信13520258486
更多>最近资讯中心
更多>最新资讯中心
0相关评论

推荐图文
推荐资讯中心
点击排行
最新信息
新手指南
采购商服务
供应商服务
交易安全
关注我们
手机网站:
新浪微博:
微信关注:

13520258486

周一至周五 9:00-18:00
(其他时间联系在线客服)

24小时在线客服