启动虚拟机,执行flutter run 后,始终卡在Running Gradle task 'assembleDebug'...这一步,头发都卡白了
1.在项目下android文件下找到build.gradle文件,如下图所示修改
//修改的地方
maven { url 'https://maven.aliyun.com/repository/google' }
maven { url 'https://maven.aliyun.com/repository/jcenter' }
maven { url 'http://maven.aliyun.com/nexus/content/groups/public' }
2.在项目中android\gradle\wrapper找到gradle-wrapper.properties文件,修改distributionUrl
distributionUrl=file\:/D\:/softWare/gradle/gradle-5.4.1-all.zip
注意,你安装的gradle版本必须和你项目配置的flutter版本想匹配,附上插件版本所需的 Gradle 版本链接 (https://www.cnblogs.com/sendling/p/13452173.html),选择安装你适配的版本!
3.在flutter sdk安装的路径 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 'http://maven.aliyun.com/nexus/content/groups/public' }
}
//修改的地方
private static final String MAVEN_REPO = "http://download.flutter.io";
project.rootProject.allprojects {
repositories {
maven {
url repository
//修改的地方
//添加
maven { url 'https://maven.aliyun.com/repository/google' }
maven { url 'https://maven.aliyun.com/repository/jcenter' }
maven { url 'http://maven.aliyun.com/nexus/content/groups/public' }
}
}
}
修改这些地方后,执行flutter clean后重新运行flutter run,发现已经运行成功,
虚拟机内也启动了flutter的demo画面,至此,大功告成~~~
网友评论