android gradle特别慢

发布于:2024-09-05 ⋅ 阅读:(63) ⋅ 点赞:(0)

gradle下载慢

修改gradle-wrapper.properties
在这里插入图片描述

替换https://services.gradle.org/distributions为https://mirrors.cloud.tencent.com/gradle

distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://mirrors.cloud.tencent.com/gradle/gradle-8.2-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists

gradle依赖包下载慢

修改settings.gradle.kts
在这里插入图片描述

pluginManagement {
    repositories {
        // 使用阿里镜像源
        maven(url = "https://maven.aliyun.com/repository/google")
        maven(url = "https://maven.aliyun.com/repository/central")
        maven(url = "https://maven.aliyun.com/repository/gradle-plugin")
        google {
            content {
                includeGroupByRegex("com\\.android.*")
                includeGroupByRegex("com\\.google.*")
                includeGroupByRegex("androidx.*")
            }
        }
        mavenCentral()
        gradlePluginPortal()
    }
}
dependencyResolutionManagement {
    repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
    repositories {
    	// 使用阿里镜像源
        maven(url = "https://maven.aliyun.com/repository/google")
        maven(url = "https://maven.aliyun.com/repository/central")
        google()
        mavenCentral()
    }
}

rootProject.name = "My Application"
include(":app")

参考

https://blog.csdn.net/moresi/article/details/136206437
https://developer.aliyun.com/mvn/guide