Android Studio下载gradle超时问题解决

方法一

  1. 配置根目录的setting.gradle.kts文件
java 复制代码
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()
        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 = "test1"
include(":app")
  1. 配置http 代理
java 复制代码
腾讯: https://mirrors.cloud.tencent.com/AndroidSDK/
阿里: https://mirrors.aliyun.com/android.googlesource.com/

##可以都试一下

方法二

配置对所有项目起效的项目环境

查看.gradle所在位置 :打开Android Studio -> File -> setting

打开你的.gradle文件,然后新建init.gradle

java 复制代码
allprojects{
    repositories {
        def MY_ALIYUN_REPOSITORY_URL = 'http://maven.aliyun.com/nexus/content/groups/public'
        def MY_ALIYUN_JCENTER_URL = 'http://maven.aliyun.com/nexus/content/repositories/jcenter'
        all { ArtifactRepository repo ->
            if(repo instanceof MavenArtifactRepository){
                def url = repo.url.toString()
                if (url.startsWith('https://repo1.maven.org/maven2')) {
                    project.logger.lifecycle "Repository ${repo.url} replaced by $MY_ALIYUN_REPOSITORY_URL."
                    remove repo
                }
                if (url.startsWith('https://jcenter.bintray.com/')) {
                    project.logger.lifecycle "Repository ${repo.url} replaced by $MY_ALIYUN_JCENTER_URL."
                    remove repo
                }
            }
        }
        maven {
            url MY_ALIYUN_REPOSITORY_URL
            url MY_ALIYUN_JCENTER_URL
        }
    }
}
相关推荐
九品神元师26 分钟前
jupyter配置说明
linux·ide·jupyter
iofomo1 小时前
Android平台从上到下,无需ROOT/解锁/刷机,应用级拦截框架的最后一环,SVC系统调用拦截。
android
我叫特踏实2 小时前
SensorManager开发参考
android·sensormanager
无码不欢的我3 小时前
使用vscode在本地和远程服务器端运行和调试Python程序的方法总结
ide·vscode·python
五味香3 小时前
Java学习,查找List最大最小值
android·java·开发语言·python·学习·golang·kotlin
PyAIGCMaster5 小时前
ollama部署及实践记录,虚拟环境,pycharm等
linux·ide·pycharm
graceyun9 小时前
C语言进阶习题【1】指针和数组(4)——指针笔试题3
android·java·c语言
2401_8979160613 小时前
Android 自定义 View _ 扭曲动效
android
天花板之恋14 小时前
Android AutoMotive --CarService
android·aaos·automotive
Le0v1n17 小时前
VSCode注释高亮(# NOTE;# TODO;# FIXME;#XXX;# HACK;# BUG)
ide·vscode·python