Android:Android Studio 配置Gradle

Android Studio 配置 Gradle,配置代理,解决外网无法访问。

Gradle配置国内镜像源

错误信息:Could not install Gradle distribution from ‘https://services.gradle.org/distributions/gradle-6.7.1-bin.zip'. Reason: java.net.SocketTimeoutException: Read timed out

错误描述:无法访问外网,网络超时

错误解决:使用国内镜像源,最简单有效的解决方案

常用的国内镜像服务
阿里云镜像:https://mirrors.aliyun.com/
腾讯云镜像:https://mirrors.cloud.tencent.com/
华为云镜像:https://mirrors.huaweicloud.com/
中科大镜像:https://mirrors.ustc.edu.cn/

在 build.gradle 文件中添加:

1
2
3
4
5
6
7
8
9
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' }
maven { url 'https://maven.aliyun.com/repository/gradle-plugin' }
google()
jcenter()
mavenCentral()
}

或 修改 gradle/wrapper/gradle-wrapper.properties 文件中的 distributionUrl

1
2
3
distributionUrl=https\://mirrors.cloud.tencent.com/gradle/gradle-6.7.1-bin.zip
# 或者使用阿里云镜像
# distributionUrl=https\://mirrors.aliyun.com/macports/distfiles/gradle/gradle-7.2-bin.zip

示例:

1
2
3
4
5
6
#Thu Dec 11 09:41:09 CST 2025
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://mirrors.aliyun.com/macports/distfiles/gradle/gradle-7.2-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists

Android:Android Studio 配置Gradle

http://blog.gxitsky.com/2025/12/11/Android-01-Gradle/

作者

光星

发布于

2025-12-11

更新于

2025-12-12

许可协议

评论