赞
踩
记录一下这个版本的as在使用国内下载源加速碰到的诸多问题。
编辑项目文件夹/gradle/wrapper/gradle-wrapper.properties,文件内容改为如下:
- #Fri Nov 24 18:50:06 CST 2023
- distributionBase=GRADLE_USER_HOME
- distributionPath=wrapper/dists
- distributionUrl=https\://mirrors.aliyun.com/macports/distfiles/gradle/gradle-8.0-bin.zip
- zipStoreBase=GRADLE_USER_HOME
- zipStorePath=wrapper/dists
点击同步即可。
先看看以前的加速配置(settings.gradle):
- pluginManagement {
- repositories {
- maven { url 'https://maven.aliyun.com/repository/central' }
- maven { url 'https://maven.aliyun.com/repository/google' }
- maven { url 'https://maven.aliyun.com/repository/gradle-plugin' }
- maven { url 'https://maven.aliyun.com/repository/jcenter' }
- maven { url 'https://maven.aliyun.com/repository/public' }
- }
- }
- dependencyResolutionManagement {
- repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
- repositories {
- maven { url 'https://maven.aliyun.com/repository/central' }
- maven { url 'https://maven.aliyun.com/repository/google' }
- maven { url 'https://maven.aliyun.com/repository/gradle-plugin' }
- maven { url 'https://maven.aliyun.com/repository/jcenter' }
- maven { url 'https://maven.aliyun.com/repository/public' }
- }
- }
- rootProject.name = "p2v"
- include ':app'
再来看看settings.gradle.kts的默认配置:
- pluginManagement {
- repositories {
- google()
- mavenCentral()
- gradlePluginPortal()
- }
- }
- dependencyResolutionManagement {
- repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
- repositories {
- google()
- mavenCentral()
- }
- }
-
- rootProject.name = "My Application"
- include(":app")
好像也相差没多少,拷贝核心代码过去试试,改后文件如下:
- pluginManagement {
- repositories {
- maven { url 'https://maven.aliyun.com/repository/central' }
- maven { url 'https://maven.aliyun.com/repository/google' }
- maven { url 'https://maven.aliyun.com/repository/gradle-plugin' }
- maven { url 'https://maven.aliyun.com/repository/jcenter' }
- maven { url 'https://maven.aliyun.com/repository/public' }
- }
- }
- dependencyResolutionManagement {
- repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
- repositories {
- maven { url 'https://maven.aliyun.com/repository/central' }
- maven { url 'https://maven.aliyun.com/repository/google' }
- maven { url 'https://maven.aliyun.com/repository/gradle-plugin' }
- maven { url 'https://maven.aliyun.com/repository/jcenter' }
- maven { url 'https://maven.aliyun.com/repository/public' }
- }
- }
-
- rootProject.name = "My Application"
- include(":app")
开始同步...
接着肯定会提示:settings.gradle.kts:3:21: Unexpected tokens (use ';' to separate expressions on the same line)
哦哦哦,kts的语法和gls不一样,再进行如下修改:
- pluginManagement {
- repositories {
- maven { url=uri("https://maven.aliyun.com/repository/central") }
- maven { url=uri("https://maven.aliyun.com/repository/google") }
- maven { url=uri("https://maven.aliyun.com/repository/gradle-plugin") }
- maven { url=uri("https://maven.aliyun.com/repository/jcenter") }
- maven { url=uri("https://maven.aliyun.com/repository/public") }
- }
- }
- dependencyResolutionManagement {
- repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
- repositories {
- maven { url=uri("https://maven.aliyun.com/repository/central") }
- maven { url=uri("https://maven.aliyun.com/repository/google") }
- maven { url=uri("https://maven.aliyun.com/repository/gradle-plugin") }
- maven { url=uri("https://maven.aliyun.com/repository/jcenter") }
- maven { url=uri("https://maven.aliyun.com/repository/public") }
- }
- }
-
- rootProject.name = "My Application"
- 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,改完文件内容如下:
- // Top-level build file where you can add configuration options common to all sub-projects/modules.
- plugins {
- id("com.android.application") version "8.0.1" apply false
- id("org.jetbrains.kotlin.android") version "1.9.0" apply false
- }
再次点击同步....
可以看到依赖库都开始在愉快的下载了....
你以为这就完了?
然后还会下载一个叫做gradle-8.0-src.zip的文件,40M左右,但下载速度非常慢只有十几kb,万幸的是它只会在第一次下载,以后就都不会了,这里就不特意去做加速了(当然也是可以的,我的第一想法是搭建本地服务器来代理文件的下载)。
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。