解决Flutter启动一直卡在 Running Gradle task ‘assembleDebug‘...

news/2024/7/24 13:20:10 标签: flutter

前言

新建了一个Flutter工程后,Run APP 却一直卡在了Running Gradle task ‘assembleDebug’… 这里。百度查询原因是因为 Gradle 的 Maven 仓库在国外, 因此需要使用阿里云的镜像地址。

1、修改项目中android/build.gradle文件

将 buildscript.repositories 下面的

//google()
//mavenCentral()

注释掉,改成

maven {
   allowInsecureProtocol = true
   url 'https://maven.aliyun.com/repository/google'
}
maven {
   allowInsecureProtocol = true
   url 'https://maven.aliyun.com/repository/jcenter'
}
maven {
   allowInsecureProtocol = true
   url 'http://maven.aliyun.com/nexus/content/groups/public'
}

allprojects.repositories 同上修改

使用"阿里云"仓库为下载源,可能会报错(gradle的仓库地址不安全警告的错误),因为配置了除 maven 中央仓库之外的其他不安全的仓库(一些国内的镜像仓库,如"阿里云"镜像仓库也是不安全的),如下所示:

A problem occurred configuring root project 'Packer'.
> Could not resolve all dependencies for configuration ':classpath'.
   > Using insecure protocols with repositories, without explicit opt-in, is unsupported. Switch Maven repository 'maven(http://maven.aliyun.com/nexus/content/groups/public/)' to redirect to a secure protocol (like HTTPS) or allow insecure protocols. See https://docs.gradle.org/7.0.2/dsl/org.gradle.api.artifacts.repositories.UrlArtifactRepository.html#org.gradle.api.artifacts.repositories.UrlArtifactRepository:allowInsecureProtocol for more details.
* Try:
Run with --info or --debug option to get more log output. Run with --scan to get full insights.

解决方法:只需要在App项目工程的 build.gradle 中,使用 allowInsecureProtocol 属性(允许gradle使用"不安全"的仓库并且不报警告信息)即可

allowInsecureProtocol = true

2、修改 Flutter SDK 中packages\flutter_tools\gradle\flutter.gradle文件

将 buildscript.repositories 下面的

//google()
//mavenCentral()

注释掉,改成

maven {
   allowInsecureProtocol = true
   url 'https://maven.aliyun.com/repository/google'
}
maven {
   allowInsecureProtocol = true
   url 'https://maven.aliyun.com/repository/jcenter'
}
maven {
   allowInsecureProtocol = true
   url 'http://maven.aliyun.com/nexus/content/groups/public'
}

将 DEFAULT_MAVEN_HOST 值修改成 "https://storage.flutter-io.cn";

private static final String DEFAULT_MAVEN_HOST = "https://storage.flutter-io.cn";


http://www.niftyadmin.cn/n/5110742.html

相关文章

前端HTML CSS JS风格规范

本文代码规范来自HTML/CSS代码开发规范文档 文件命名规范 使用小写字母、数字和下划线组成文件名。 避免使用特殊字符和空格。 使用语义化的命名,能够清晰地表达出文件的功能或内容。 目录结构规范 使用约定俗成的目录结构,如:src/compon…

JavaPTA练习题 7-2 sdut-入门-交换两个整数的值

交换两个变量的值,由终端输入两个整数给变量x,y,然后交换x和y的值后,输出x和y. 输入格式: 从键盘输入两个整数变量x和y。中间有1个空格。 输出格式: 交换x、y的值,将x和y输出,中间有1个空格。 输入样例: 4 6输出…

23. Docker image Digest你真的了解吗?

我们知道镜像的版本是通过tag来实现的。一般我们通过版本号来识别镜像。但是随时大量的实践,我们发现黑客可以篡改这个镜像,毕竟Docker是个集装箱,我们并不能天天解压文件来检查它有没有木马。所以,Docker 镜像增加了Digest的,类似如下: quay.io/cilium/cilium:v1.12.3@…

从苏宁电器到卡巴斯基(第二部)第33篇:我当高校教师的这几年 IX

目录 送走第一批毕业生 校区转型升级 送走第一批毕业生 时间过得很快,我在X高校所指导的第一批本科生(2019届)就快要毕业了。其实在整个指导的过程中,我感触最深的一件事情就是,作为一个本科是市场营销,研究生才跨专业学习软件工程的人来说,以前都是为自己的毕业论文而…

水管安装过滤器笔记

文章目录 方案准备工具剪管钳热熔器软管接头及单向阀扳手 操作过程花洒 搬家后,水质不行,洗脸掉皮,洗头以前不掉头皮屑的,居然也掉头皮屑。有必要简单过滤下了。 水质情况,并不是脏脏的的那种水,看上去还比…

冷知识:unity使用的是左手坐标系

三维软件使用的坐标系分为:左手坐标系和右手坐标系 unity使用左手坐标系(高中立体几何使用的坐标系) 左手坐标系和右手坐标系的区分方法: 在空间直角坐标系中,让左手拇指指向x轴的正方向,食指指向y轴的…

二阶系统时域响应

二阶系统微分方程 二阶系统传递函数 二阶系统单位阶跃响应 过阻尼系统 临界阻尼系统 欠阻尼系统 无阻尼系统 二阶系统阶跃响应仿真 在Matlab中进行仿真,设置不同阻尼比2、1、0.5和0,可以得到结论: 阻尼比越小,系统响应速度越快&…

【CSS】全局滚动条样式设置

直接在 App.vue 全局文件下设置滚动条样式: ::-webkit-scrollbar {width: 5px;position: absolute; } ::-webkit-scrollbar-thumb {background: #1890ff; } ::-webkit-scrollbar-track {background: #ddd; }