问题:
Android studio 配置 Flutter之后新建项目一直卡在Initlizing gradle哪里。
分析:
在gradle-wrapper.properties文件中我们能看到distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.2-all.zip
。一直卡住的原因就是,as自动下载gradle,结果被国家屏蔽外网了,所以一直下载不了。
解决:
阿里提供了响应的maven仓库,可以从ali下载。只需要改一下配置文件。为了彻底解决,同时修改Flutter和项目的配置文件。
1.Flutter
文件路径为:flutter>packages>flutter_tools>gradle>flutter.gradle
repositories {
//google()
//jcenter()
maven{url 'https://maven.aliyun.com/repository/google'}
maven{url 'https://maven.aliyun.com/repository/jcenter'}
maven{url 'https://maven.aliyun.com/nexus/content/groups/public'}
}
2.项目
buildscript {
repositories {
//google()
//jcenter()
maven{url 'https://maven.aliyun.com/repository/google'}
maven{url 'https://maven.aliyun.com/repository/jcenter'}
maven{url 'https://maven.aliyun.com/nexus/content/groups/public'}
}
dependencies {
classpath 'com.android.tools.build:gradle:3.2.1'
}
}
allprojects {
repositories {
//google()
//jcenter()
maven{url 'https://maven.aliyun.com/repository/google'}
maven{url 'https://maven.aliyun.com/repository/jcenter'}
maven{url 'https://maven.aliyun.com/nexus/content/groups/public'}
}
}
rootProject.buildDir = '../build'
subprojects {
project.buildDir = "${rootProject.buildDir}/${project.name}"
}
subprojects {
project.evaluationDependsOn(':app')
}
task clean(type: Delete) {
delete rootProject.buildDir
}