作者:wo叫天然呆链接:https://www.jianshu.com/p/2225481a26f8来源:简书著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。
平时安卓项目编译较慢,其中一个原因就是要下载依赖资源包比较慢。为了解决这个问题,可以配置阿里云镜像,加速下载
关于阿里云的镜像可以查看他们的阿里云云效 Maven或者是公共代理库
常规做法
以前拿到项目或者是网上的开源库,觉得下载依赖包太慢的时候,我们都是直接在项目根目录下的build.gradle中添加阿里的镜像,这样虽然说能解决下载依赖包慢的问题,但是每次都这么搞一次也是很费事
buildscript{
repositories{
/* google()
jcenter()*/
maven{ url'https://maven.aliyun.com/repository/gradle-plugin' }
maven{ url'https://maven.aliyun.com/repository/google' }
maven{ url'http://maven.aliyun.com/nexus/content/groups/public/' }
maven{ url'https://maven.aliyun.com/repository/jcenter'}
}
dependencies{
classpath"com.android.tools.build:gradle:4.0.1"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects{
repositories{
/* google()
jcenter()*/
maven{ url'https://maven.aliyun.com/repository/gradle-plugin' }
maven{ url'https://maven.aliyun.com/repository/google' }
maven{ url'http://maven.aliyun.com/nexus/content/groups/public/' }
maven{ url'https://maven.aliyun.com/repository/jcenter'}
}
}
全局配置(对所有项目生效)
先在$GRADLE_USER_HOME/.gradle目录下创建一个叫init.gradle的文件
然后输入以下内容
网友评论