android studio总是更新,还总是慢,怎么办呢?
在 ~/.gradle 下面创建 init.gradle 文件,内容如下,重启android studio
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
allprojects{ repositories { def MY_ALIYUN_REPOSITORY_URL = 'https://maven.aliyun.com/nexus/content/groups/public' def MY_ALIYUN_JCENTER_URL = 'https://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 $MY_ALIYUN_REPOSITORY_URL." remove repo } if (url.startsWith('https://jcenter.bintray.com/')) { project.logger.lifecycle "Repository ${repo.url} replaced by $MY_ALIYUN_JCENTER_URL." remove repo } } } maven { url MY_ALIYUN_REPOSITORY_URL url MY_ALIYUN_JCENTER_URL } } } |
另外,还要注意一下自己有没有配置代理,参考 .gradle/gradle.properties,因为走阿里云就可以不用代理就能很快了。
我的init.gradle 文件在 d:\.gradle 目录下