当前位置:   article > 正文

Android Studio下载gradle超时问题解决_android gradle下载超时

android gradle下载超时

方法一

        1. 配置根目录的setting.gradle.kts文件

  1. pluginManagement {
  2. repositories {
  3. maven { url=uri ("https://www.jitpack.io")}
  4. maven { url=uri ("https://maven.aliyun.com/repository/releases")}
  5. maven { url=uri ("https://maven.aliyun.com/repository/google")}
  6. maven { url=uri ("https://maven.aliyun.com/repository/central")}
  7. maven { url=uri ("https://maven.aliyun.com/repository/gradle-plugin")}
  8. maven { url=uri ("https://maven.aliyun.com/repository/public")}
  9. google()
  10. mavenCentral()
  11. gradlePluginPortal()
  12. }
  13. }
  14. dependencyResolutionManagement {
  15. repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
  16. repositories {
  17. maven { url=uri ("https://www.jitpack.io")}
  18. maven { url=uri ("https://maven.aliyun.com/repository/releases")}
  19. maven { url=uri ("https://maven.aliyun.com/repository/google")}
  20. maven { url=uri ("https://maven.aliyun.com/repository/central")}
  21. maven { url=uri ("https://maven.aliyun.com/repository/gradle-plugin")}
  22. maven { url=uri ("https://maven.aliyun.com/repository/public")}
  23. google()
  24. mavenCentral()
  25. }
  26. }
  27. rootProject.name = "test1"
  28. include(":app")

        2. 配置http 代理

 

  1. 腾讯: https://mirrors.cloud.tencent.com/AndroidSDK/
  2. 阿里: https://mirrors.aliyun.com/android.googlesource.com/
  3. ##可以都试一下

方法二

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

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

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

  1. allprojects{
  2. repositories {
  3. def MY_ALIYUN_REPOSITORY_URL = 'http://maven.aliyun.com/nexus/content/groups/public'
  4. def MY_ALIYUN_JCENTER_URL = 'http://maven.aliyun.com/nexus/content/repositories/jcenter'
  5. all { ArtifactRepository repo ->
  6. if(repo instanceof MavenArtifactRepository){
  7. def url = repo.url.toString()
  8. if (url.startsWith('https://repo1.maven.org/maven2')) {
  9. project.logger.lifecycle "Repository ${repo.url} replaced by $MY_ALIYUN_REPOSITORY_URL."
  10. remove repo
  11. }
  12. if (url.startsWith('https://jcenter.bintray.com/')) {
  13. project.logger.lifecycle "Repository ${repo.url} replaced by $MY_ALIYUN_JCENTER_URL."
  14. remove repo
  15. }
  16. }
  17. }
  18. maven {
  19. url MY_ALIYUN_REPOSITORY_URL
  20. url MY_ALIYUN_JCENTER_URL
  21. }
  22. }
  23. }

本文内容由网友自发贡献,转载请注明出处:https://www.wpsshop.cn/w/盐析白兔/article/detail/795661
推荐阅读
相关标签
  

闽ICP备14008679号