解决AndroidStudio下载Gradle依赖、SDK、maven速度慢

解决方法(Kotlin)

修改项目根路径下gradle.properties文件,添加如下内容

systemProp.gradle.download.url=https://mirrors.aliyun.com/gradle/

修改项目根路径下settings.gradle.kts文件中的 pluginManagement dependencyResolutionManagement

修改后部分内容如下

pluginManagement {
    repositories {
        maven { setUrl("https://maven.aliyun.com/repository/central") }
        maven { setUrl("https://maven.aliyun.com/repository/google") }
        maven { setUrl("https://maven.aliyun.com/repository/jcenter") }
        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/google") }
        maven { setUrl("https://maven.aliyun.com/repository/jcenter") }
        google()
        mavenCentral()
    }
}

修改gradle-wrapper.properties添加如下内容

需要把代码中gradle的版本改为和你原有的地址中的版本相同

distributionUrl=https\://mirrors.cloud.tencent.com/gradle/gradle-7.5-bin.zip

在C:/Windows/System32/drivers/etc/hosts文件中添加

180.163.150.33 google.com

解决方法(Java)

 修改项目根路径下gradle.properties文件,添加如下内容

systemProp.gradle.download.url=https://mirrors.aliyun.com/gradle/

修改项目根路径下settings.gradle文件中的 pluginManagement dependencyResolutionManagement

修改后部分内容如下

pluginManagement {
    repositories {
        maven { setUrl("https://maven.aliyun.com/repository/central") }
        maven { setUrl("https://maven.aliyun.com/repository/google") }
        maven { setUrl("https://maven.aliyun.com/repository/jcenter") }
        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/google") }
        maven { setUrl("https://maven.aliyun.com/repository/jcenter") }
        google()
        mavenCentral()
    }
}

猜你喜欢

转载自blog.csdn.net/ydk1203/article/details/142625864