赞
踩
上一篇写到maven导包失败的解决方法,就联想到gradle中也遇到过这样的问题,导包download failed的情形。
解决方法参考了博客Could not download kotlin-compiler-embeddable.jar,采取方法二,Windows系统默认下载到:C:\Users(用户名).gradle,新建init.gradle
allprojects{ repositories { def ALIYUN_REPOSITORY_URL = 'https://maven.aliyun.com/repository/central/' def ALIYUN_JCENTER_URL = 'https://maven.aliyun.com/repository/public/' all { ArtifactRepository repo -> if(repo instanceof MavenArtifactRepository){ def url = repo.url.toString() if (url.startsWith('https://repo1.maven.org/maven2') || url.startsWith('http://repo1.maven.org/maven2')) { project.logger.lifecycle "Repository ${repo.url} replaced by $ALIYUN_REPOSITORY_URL." remove repo } if (url.startsWith('https://jcenter.bintray.com/') || url.startsWith('http://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 url 'https://maven.aliyun.com/repository/google/' url 'https://maven.aliyun.com/repository/gradle-plugin/' } } buildscript{ repositories { def ALIYUN_REPOSITORY_URL = 'https://maven.aliyun.com/repository/central/' def ALIYUN_JCENTER_URL = 'https://maven.aliyun.com/repository/public/' all { ArtifactRepository repo -> if(repo instanceof MavenArtifactRepository){ def url = repo.url.toString() if (url.startsWith('https://repo1.maven.org/maven2') || url.startsWith('http://repo1.maven.org/maven2')) { project.logger.lifecycle "Repository ${repo.url} replaced by $ALIYUN_REPOSITORY_URL." remove repo } if (url.startsWith('https://jcenter.bintray.com/') || url.startsWith('http://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 url 'https://maven.aliyun.com/repository/google/' url 'https://maven.aliyun.com/repository/gradle-plugin/' } } } }
但是在这样设置后也遇到过问题
因为kolin问题,将google改为了阿里云镜像,造成 Could not find aapt2-proto.jar (com.android.tools.build:aapt2-proto:0.3.1).
的问题,移除init.gradle即恢复正常。
所以在设置镜像时还是在所用项目中添加比较保险。
即在build.gradle中 两个repositories 添加
maven {url 'https://maven.aliyun.com/repository/public/';}
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。