解决Android Studio项目加载过慢问题
解决方案替换掉谷歌原地址:
(1)官网地址:https://services.gradle.org/distributions/
(2)腾讯镜像 Gradle下载地址:https://mirrors.cloud.tencent.com/gradle/
(3)阿里云镜像 Gradle下载地址:https://mirrors.aliyun.com/macports/distfiles/gradle/
把官方下载地址替换成腾讯或者阿里云的地址
原来:
#Fri Sep 13 11:10:13 CST 2024
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\:/services.gradle.org/distributions/gradle-8.7-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
修改之后
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://mirrors.cloud.tencent.com/gradle/gradle-8.7-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
同时,对于 Maven 仓库的镜像,也可以在 build.gradle 文件中进行配置。例如,使用阿里云的 Maven 镜像:
buildscript {
repositories {
maven { url 'https://maven.aliyun.com/repository/google' }
maven { url 'https://maven.aliyun.com/repository/jcenter' }
maven { url 'https://maven.aliyun.com/repository/public' }
}
}
allprojects {
repositories {
maven { url 'https://maven.aliyun.com/repository/google' }
maven { url 'https://maven.aliyun.com/repository/jcenter' }
maven { url 'https://maven.aliyun.com/repository/public' }
}
}
以上配置将 Gradle 和 Maven 仓库的地址更改为阿里云的镜像地址,这样可以显著提高下载依赖的速度。