当我们在Android Studio中新建项目或者打开已有项目时,会下载gradle文件,当使用官方的下载源时很慢,经常会下载失败,国内我们可以使用腾讯或者阿里的镜像,一般下载速度很快。
一、gradle下载地址
- 官网地址:https://services.gradle.org/distributions/
- 腾讯镜像 gradle下载地址:https://mirrors.cloud.tencent.com/gradle/
- 阿里云镜像 gradle下载地址:https://mirrors.aliyun.com/macports/distfiles/gradle/
二、修改项目中distributionUrl地址gradle的配置
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
#distributionUrl=https\://services.gradle.org/distributions/gradle-8.6-bin.zip
distributionUrl=https\://mirrors.cloud.tencent.com/gradle/gradle-8.6-all.zip
#distributionUrl=https://mirrors.aliyun.com/macports/distfiles/gradle/gradle-8.6-all.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
腾讯镜像和阿里云镜像选择一个即可
三、修改项目中gradle的配置
添加项目配置官方库和三方库下载镜像
maven { url=uri ("https://www.jitpack.io")}
maven { url=uri ("https://maven.aliyun.com/repository/releases")}
maven { url=uri ("https://maven.aliyun.com/repository/google")}
maven { url=uri ("https://maven.aliyun.com/repository/central")}
maven { url=uri ("https://maven.aliyun.com/repository/gradle-plugin")}
maven { url=uri ("https://maven.aliyun.com/repository/public")}
pluginManagement {
repositories {
maven { url=uri ("https://www.jitpack.io")}
maven { url=uri ("https://maven.aliyun.com/repository/releases")}
maven { url=uri ("https://maven.aliyun.com/repository/google")}
maven { url=uri ("https://maven.aliyun.com/repository/central")}
maven { url=uri ("https://maven.aliyun.com/repository/gradle-plugin")}
maven { url=uri ("https://maven.aliyun.com/repository/public")}
google {
content {
includeGroupByRegex("com\\.android.*")
includeGroupByRegex("com\\.google.*")
includeGroupByRegex("androidx.*")
}
}
mavenCentral()
gradlePluginPortal()
}
}
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
maven { url=uri ("https://www.jitpack.io")}
maven { url=uri ("https://maven.aliyun.com/repository/releases")}
maven { url=uri ("https://maven.aliyun.com/repository/google")}
maven { url=uri ("https://maven.aliyun.com/repository/central")}
maven { url=uri ("https://maven.aliyun.com/repository/gradle-plugin")}
maven { url=uri ("https://maven.aliyun.com/repository/public")}
google()
mavenCentral()
}
}
rootProject.name = "TestDemo"
include(":app")