安卓下載各種東西慢
我們經(jīng)常運(yùn)行別人組件的時(shí)候辽社,發(fā)現(xiàn)各種下載失敗,各種下載緩慢 請(qǐng)使用國(guó)內(nèi)鏡像翘鸭,飛一般的趕腳滴铅。
a. 替換google()和jcenter()
google()
jcenter()
替換為下面
maven { url 'https://maven.aliyun.com/repository/google' }
//central倉(cāng)和jcenter倉(cāng)的聚合倉(cāng)
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.全局替換倉(cāng)庫(kù)地址
在 ${USER_HOME}.gradle 新建init.gradle,文件內(nèi)容如下
```
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}}}
```