当前位置:   article > 正文

AndroidStudio2022.3.1 Patch3使用国内下载源加速_android studio 2022.3.1下载

android studio 2022.3.1下载

记录一下这个版本的as在使用国内下载源加速碰到的诸多问题。

一、gradle-8.0-bin.zip下载慢

编辑项目文件夹/gradle/wrapper/gradle-wrapper.properties,文件内容改为如下:

  1. #Fri Nov 24 18:50:06 CST 2023
  2. distributionBase=GRADLE_USER_HOME
  3. distributionPath=wrapper/dists
  4. distributionUrl=https\://mirrors.aliyun.com/macports/distfiles/gradle/gradle-8.0-bin.zip
  5. zipStoreBase=GRADLE_USER_HOME
  6. zipStorePath=wrapper/dists

点击同步即可。

二、使用阿里云加速报错(kts版本)

先看看以前的加速配置(settings.gradle):

  1. pluginManagement {
  2. repositories {
  3. maven { url 'https://maven.aliyun.com/repository/central' }
  4. maven { url 'https://maven.aliyun.com/repository/google' }
  5. maven { url 'https://maven.aliyun.com/repository/gradle-plugin' }
  6. maven { url 'https://maven.aliyun.com/repository/jcenter' }
  7. maven { url 'https://maven.aliyun.com/repository/public' }
  8. }
  9. }
  10. dependencyResolutionManagement {
  11. repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
  12. repositories {
  13. maven { url 'https://maven.aliyun.com/repository/central' }
  14. maven { url 'https://maven.aliyun.com/repository/google' }
  15. maven { url 'https://maven.aliyun.com/repository/gradle-plugin' }
  16. maven { url 'https://maven.aliyun.com/repository/jcenter' }
  17. maven { url 'https://maven.aliyun.com/repository/public' }
  18. }
  19. }
  20. rootProject.name = "p2v"
  21. include ':app'

再来看看settings.gradle.kts的默认配置:

  1. pluginManagement {
  2. repositories {
  3. google()
  4. mavenCentral()
  5. gradlePluginPortal()
  6. }
  7. }
  8. dependencyResolutionManagement {
  9. repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
  10. repositories {
  11. google()
  12. mavenCentral()
  13. }
  14. }
  15. rootProject.name = "My Application"
  16. include(":app")

好像也相差没多少,拷贝核心代码过去试试,改后文件如下:

  1. pluginManagement {
  2. repositories {
  3. maven { url 'https://maven.aliyun.com/repository/central' }
  4. maven { url 'https://maven.aliyun.com/repository/google' }
  5. maven { url 'https://maven.aliyun.com/repository/gradle-plugin' }
  6. maven { url 'https://maven.aliyun.com/repository/jcenter' }
  7. maven { url 'https://maven.aliyun.com/repository/public' }
  8. }
  9. }
  10. dependencyResolutionManagement {
  11. repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
  12. repositories {
  13. maven { url 'https://maven.aliyun.com/repository/central' }
  14. maven { url 'https://maven.aliyun.com/repository/google' }
  15. maven { url 'https://maven.aliyun.com/repository/gradle-plugin' }
  16. maven { url 'https://maven.aliyun.com/repository/jcenter' }
  17. maven { url 'https://maven.aliyun.com/repository/public' }
  18. }
  19. }
  20. rootProject.name = "My Application"
  21. include(":app")

开始同步...

接着肯定会提示:settings.gradle.kts:3:21: Unexpected tokens (use ';' to separate expressions on the same line)

哦哦哦,kts的语法和gls不一样,再进行如下修改:

  1. pluginManagement {
  2. repositories {
  3. maven { url=uri("https://maven.aliyun.com/repository/central") }
  4. maven { url=uri("https://maven.aliyun.com/repository/google") }
  5. maven { url=uri("https://maven.aliyun.com/repository/gradle-plugin") }
  6. maven { url=uri("https://maven.aliyun.com/repository/jcenter") }
  7. maven { url=uri("https://maven.aliyun.com/repository/public") }
  8. }
  9. }
  10. dependencyResolutionManagement {
  11. repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
  12. repositories {
  13. maven { url=uri("https://maven.aliyun.com/repository/central") }
  14. maven { url=uri("https://maven.aliyun.com/repository/google") }
  15. maven { url=uri("https://maven.aliyun.com/repository/gradle-plugin") }
  16. maven { url=uri("https://maven.aliyun.com/repository/jcenter") }
  17. maven { url=uri("https://maven.aliyun.com/repository/public") }
  18. }
  19. }
  20. rootProject.name = "My Application"
  21. include(":app")

再次点击同步.....

再次报出错误:Plugin [id: 'com.android.application', version: '8.1.3', apply: false] was not found in any of the following sources

eem.....大概意思是找不到相关的依赖库,上阿里云仓库查询了一下,是有这个com.android.application 8.1.3 库的,那是什么原因呢?

再往下翻翻错误日志,找到核心错误:Plugin Repositories (could not resolve plugin artifact 'com.android.application:com.android.application.gradle.plugin:8.1.3')

再次然上阿里云仓库查询了一下,是有com.android.application.gradle.plugin这个库的,但是没有8.1.3版本(as里的默认使用的版本),于是改成阿里云仓库里有的版本,编辑项目文件夹/build.gradle.kts,改完文件内容如下:

  1. // Top-level build file where you can add configuration options common to all sub-projects/modules.
  2. plugins {
  3. id("com.android.application") version "8.0.1" apply false
  4. id("org.jetbrains.kotlin.android") version "1.9.0" apply false
  5. }

再次点击同步....

可以看到依赖库都开始在愉快的下载了....

你以为这就完了?

然后还会下载一个叫做gradle-8.0-src.zip的文件,40M左右,但下载速度非常慢只有十几kb,万幸的是它只会在第一次下载,以后就都不会了,这里就不特意去做加速了(当然也是可以的,我的第一想法是搭建本地服务器来代理文件的下载)。

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

闽ICP备14008679号