当前位置:   article > 正文

Android Studio配置国内镜像源和HTTP代理/解决:Android Studio下载gradle速度慢的问题_android studio 下载 镜像

android studio 下载 镜像

(方案一)Android Studio配置国内镜像源和HTTP代理

一、配置国内镜像源/依赖库
1.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 = "HelloWorld"
  28. include(":app")

然后填入镜像地址

  1. 腾讯: https://mirrors.cloud.tencent.com/AndroidSDK/
  2. 阿里: https://mirrors.aliyun.com/android.googlesource.com/

(推荐笔者使用的 方案二)解决:Android Studio下载gradle速度慢的问题

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

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

文件夹中打开Gradle user home显示的路径,在.gradle文件夹中创建init.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. }

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/菜鸟追梦旅行/article/detail/273665
推荐阅读
相关标签
  

闽ICP备14008679号