Android studio 无法下载库的问题

2018-12-19  本文已影响0人  不问何处有明月

有时 as 载入库时特别慢,有时还失败。

我们可以用阿里云代理。

在电脑目录:C:\Users\用户名.gradle 目录下,创建 init.gradle.txt 文件。

输入:

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

这时就可以用阿里云代理 下载了。

上一篇下一篇

猜你喜欢

热点阅读