问题
构建Android项目时卡在Gradle: Download gradle-8.2-src.zip
解决
从 Android Studio Dolphin 2021.3.1 之后,国内源的切换配置就从 build.gradle 文件改到了 settings.gradle 文件。
- 找到settings.gradle
- 修改settings.gradle如下
pluginManagement {
repositories {
// 改为阿里云的镜像地址
maven { setUrl("https://maven.aliyun.com/repository/central") }
maven { setUrl("https://maven.aliyun.com/repository/jcenter") }
maven { setUrl("https://maven.aliyun.com/repository/google") }
maven { setUrl("https://maven.aliyun.com/repository/gradle-plugin") }
maven { setUrl("https://maven.aliyun.com/repository/public") }
maven { setUrl("https://jitpack.io") }
maven { setUrl("https://maven.aliyun.com/nexus/content/groups/public/") }
maven { setUrl("https://maven.aliyun.com/nexus/content/repositories/jcenter") }
gradlePluginPortal()
google()
mavenCentral()
}
}
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
// 改为阿里云的镜像地址
maven { setUrl("https://maven.aliyun.com/repository/central") }
maven { setUrl("https://maven.aliyun.com/repository/jcenter") }
maven { setUrl("https://maven.aliyun.com/repository/google") }
maven { setUrl("https://maven.aliyun.com/repository/gradle-plugin") }
maven { setUrl("https://maven.aliyun.com/repository/public") }
maven { setUrl("https://jitpack.io") }
google()
mavenCentral()
}
}
//下面两行用你自己的,不需要改
rootProject.name = "A01_First_App"
include(":app")
- 重新构建项目(用手机热点的网络效果好一些)
参考
https://www.sunzhongwei.com/android-studio-settings-gradle-switching-source-in-china