android镜像源

安卓下载各种东西慢

我们经常运行别人组件的时候,发现各种下载失败,各种下载缓慢 请使用国内镜像,飞一般的赶脚。

a. 替换google()和jcenter()

google()

jcenter()

替换为下面

//google

maven { url 'https://maven.aliyun.com/repository/google' }

//central仓和jcenter仓的聚合仓

maven { url 'https://maven.aliyun.com/repository/public' }

//gradle-plugin

maven { url 'https://maven.aliyun.com/repository/gradle-plugin' }

b. 替换grade下载地址 将上面的替换成下面镜像

#distributionUrl=https\://services.gradle.org/distributions/gradle-5.1.1-all.zip#csdn镜像distributionUrl=https\://downloads.gradle-dn.com/distributions/gradle-5.1.1-all.zip

c.全局替换仓库地址

在 ${USER_HOME}.gradle 新建init.gradle,文件内容如下

```

allprojects{repositories{defREPOSITORY_URL='http://maven.oschina.net/content/groups/public'all{ArtifactRepositoryrepo->if(repo instanceofMavenArtifactRepository){defurl=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{urlREPOSITORY_URL}}}

```

你可能感兴趣的:(android镜像源)