flutter开发的一个小小小问题,内网依赖下不来

news/2024/10/22 16:51:54/

问题

由于众所周知的原因,flutter编译时,经常出现Could not get resource 'https://storage.googleapis.com/download.flutter.io…'的问题,如下:

* What went wrong:
Could not determine the dependencies of task ':app:lintVitalRelease'.
> Could not resolve all artifacts for configuration ':app:debugCompileClasspath'.> Could not download armeabi_v7a_debug-1.0.0-cdbeda788a293fa29665dc3fa3d6e63bd221cb0d.jar (io.flutter:armeabi_v7a_debug:1.0.0-cdbeda788a293fa29665dc3fa3d6e63bd221cb0d)> Could not get resource 'https://storage.googleapis.com/download.flutter.io/io/flutter/armeabi_v7a_debug/1.0.0-cdbeda788a293fa29665dc3fa3d6e63bd221cb0d/armeabi_v7a_debug-1.0.0-cdbeda788a293fa2966
5dc3fa3d6e63bd221cb0d.jar'.> Could not GET 'https://storage.googleapis.com/download.flutter.io/io/flutter/armeabi_v7a_debug/1.0.0-cdbeda788a293fa29665dc3fa3d6e63bd221cb0d/armeabi_v7a_debug-1.0.0-cdbeda788a293fa29665dc3fa
3d6e63bd221cb0d.jar'.> Connection reset* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.* Get more help at https://help.gradle.orgBUILD FAILED in 5s
Running Gradle task 'assembleRelease'...                            6.4s
[!] Gradle threw an error while downloading artifacts from the network.
Retrying Gradle Build: #12, wait time: 204800ms

解决

修改flutter中gradle的仓库配置,目录为:D:\google\flutter\packages\flutter_tools\gradle
在这里插入图片描述
打开flutter.gradle,然后修改仓库信息为:http://mirror.nju.edu.cn/flutter,如下:

    // private static final String DEFAULT_MAVEN_HOST = "https://storage.googleapis.com";private static final String DEFAULT_MAVEN_HOST = "http://mirror.nju.edu.cn/flutter";

分析

然后,我又看了下flutter.gradle里面的代码,给大家看看:

        // Configure the Maven repository.String hostedRepository = System.env.FLUTTER_STORAGE_BASE_URL ?: DEFAULT_MAVEN_HOSTString repository = useLocalEngine()? project.property('local-engine-repo'): "$hostedRepository/download.flutter.io"rootProject.allprojects {repositories {maven {url repository}}}

真是自作孽不可活,明明有FLUTTER_STORAGE_BASE_URL这个环境变量可以去设置,自己懒不设置,活该!

快捷

跟我一样懒惰的兄弟们,给你们把链接奉上,https://docs.flutter.dev/community/china
在这里插入图片描述
自取,去设置环境变量,别懒得一坨耙耙一样了!!!


http://www.ppmy.cn/news/1169179.html

相关文章

Java开发规范记录

不要使用 count(column)或 count(1)来替代 count(*),count(*)是 SQL92 定义的 标准统计行数的语法,跟数据库无关,跟 NULL 和非 NULL 无关。 注意:count(*)会统计值为 NULL 的行,而 count(列名)不会统计此列为 NULL 值的…

idea + Docker-Compose 实现自动化打包部署(仅限测试环境)

一、修改docker.service文件,添加监听端口 vi /usr/lib/systemd/system/docker.service ExecStart/usr/bin/dockerd -H fd:// --containerd/run/containerd/containerd.sock -H tcp://0.0.0.0:2375 -H unix://var/run/docker.sock重启docker服务 systemctl daemo…

towxml的使用,在微信小程序中快速将markdown格式渲染为wxml文本

towxml的使用,在微信小程序中快速将markdown格式渲染为wxml文本 Towxml概述安装下载 Towxml在小程序中使用 towxml Towxml概述 towxml3.0 支持以下功能: ● echarts图表,默认禁用,需自行构建以开启此功能 ● LaTeX数学公式&#…

python在nacos注册微服务

安装 首先需要安装python的nacos sdk pip install nacos-sdk-python 注册 注册过程非常简单,需要注意的是,注册完要定时发送心跳,否则服务会被nacos删掉。 import nacos import timeSERVER_ADDRESSES "http://1.2.3.4:8848" …

插入排序(学习笔记)

插入排序 每一轮插入排序后的结果与打扑克牌取牌原理相似,将取到的牌插入到合适的位置,但在程序实现方面还是基于交换的算法。 它的基本思想是将一个记录插入到已经排好序的有序表中,从而一个新的、记录数增1的有序表。 import java.util.…

容器技术基础

1. Linux Namespace和Cgroups 对于 Docker 等大多数 Linux 容器来说,Cgroups 技术是用来制造约束的主要手段,而 Namespace 技术则是用来修改进程视图的主要方法。 1.1 PID Namespace //Linux 系统正常创建线程 int pid clone(main_function, stack_s…

负采样:如何高效训练词向量

Negative Sampling 1.何为负采样 负采样是一种用于训练词嵌入模型的采样方法,特别适用于处理大规模词汇表的情况。负采样的目标是降低计算成本并改善模型的性能,同时有效地训练词向量。 2.为什么需要负采样 在传统的词嵌入模型中,如Word…

PHP来判断地址信息中是否包含“香港“、“澳门“或“台湾“等

你可以使用PHP来判断地址信息中是否包含"香港"、"澳门"或"台湾"等词汇。以下是一个示例代码: $addressInfo "香港特别行政区中环坚道甲地上段8号";// 创建一个包含需要检查的词汇的数组 $keywords ["香港", &…