由於牆的存在,安卓開發者在使用android studio開發時,總會遇到下載庫或者升級卡着不動的情況。如果有個代理鏡像服務器,可以幫我們從國外下載,然后再映射到國內服務器該多好。感謝阿里,提供了鏡像服務器。
讓項目通過阿里雲 maven jcenter 下載依賴資源
打開項目根目錄下的 build.gradle(Project:項目名稱一級的gradle),如下所示添加阿里 maven 庫地址:
buildscript { repositories { // 添加阿里雲 maven 地址 maven { url 'http://maven.aliyun.com/nexus/content/groups/public/' } maven { url 'http://maven.aliyun.com/nexus/content/repositories/jcenter' } google() jcenter() } dependencies { classpath 'com.android.tools.build:gradle:3.4.1' } } allprojects { repositories { // 添加阿里雲 maven 地址 maven { url 'http://maven.aliyun.com/nexus/content/groups/public/' } maven { url 'http://maven.aliyun.com/nexus/content/repositories/jcenter' } google() jcenter() maven { url 'https://jitpack.io' } } } task clean(type: Delete) { delete rootProject.buildDir }
重新 Make Project 項目,編譯時的資源下載一般就會順暢了。