一、gradle加载太慢
android studio在创建项目的时候会联网下载gradle,但是由于墙的问题下载十分慢,导致项目的android文件夹无法出来(如下图)
解决办法:
第一步
%USERPROFILE%\.gradle\wrapper\dists
cmd运行找到dist文件夹
在官网下载对应版本gradle压缩包放到dist文件下,不用解压缩(如何查找版本如下图)
附gradle压缩下载地址
第二步:修改镜像仓库
打开build.gradle修改镜像
主要设置
在 buildscript 和 allprojects 的 repositories 分别添加
maven { url 'https://maven.aliyun.com/repository/gradle-plugin' } //gradle 国内镜像仓
maven { url 'https://maven.aliyun.com/repository/google' } //google 国内镜像仓
maven { url 'https://maven.aliyun.com/repository/jcenter' } //jcenter 国内镜像仓
【最终配置如下】
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
maven { url 'https://maven.aliyun.com/repository/gradle-plugin' } //gradle 国内镜像仓
maven { url 'https://maven.aliyun.com/repository/google' } //google 国内镜像仓
maven { url 'https://maven.aliyun.com/repository/jcenter' } //jcenter 国内镜像仓
google()
jcenter()
}
dependencies {
classpath "com.android.tools.build:gradle:4.1.1"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
maven { url 'https://maven.aliyun.com/repository/gradle-plugin' } //gradle 国内镜像仓
maven { url 'https://maven.aliyun.com/repository/google' } //google 国内镜像仓
maven { url 'https://maven.aliyun.com/repository/jcenter' } //jcenter 国内镜像仓
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}