由于墙的存在,安卓开发者在使用android studio开发时,总会遇到下载库或者升级卡着不动的情况。如果有个代理镜像服务器,可以帮我们从国外下载,然后再映射到国内服务器该多好。感谢阿里,提供了镜像服务器。
让项目通过阿里云 maven jcenter 下载依赖资源
打开项目根目录下的 build.gradle(Project:项目名称一级的gradle),如下所示添加阿里 maven 库地址:
1 buildscript {
2
3
4 repositories {
5 // 添加阿里云 maven 地址
6 maven { url 'http://maven.aliyun.com/nexus/content/groups/public/' }
7 maven { url 'http://maven.aliyun.com/nexus/content/repositories/jcenter' }
8
9 google()
10 jcenter()
11
12 }
13 dependencies {
14 classpath 'com.android.tools.build:gradle:3.4.1'
15 }
16 }
17
18 allprojects {
19 repositories {
20 // 添加阿里云 maven 地址
21 maven { url 'http://maven.aliyun.com/nexus/content/groups/public/' }
22 maven { url 'http://maven.aliyun.com/nexus/content/repositories/jcenter' }
23
24 google()
25 jcenter()
26
27 maven { url 'https://jitpack.io' }
28 }
29 }
30
31 task clean(type: Delete) {
32 delete rootProject.buildDir
33 }
重新 Make Project 项目,编译时的资源下载一般就会顺畅了。
来源:https://www.cnblogs.com/best-hym/p/12251123.html