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

阿里云国内75折 回扣 微信号:monov8
阿里云国际,腾讯云国际,低至75折。AWS 93折 免费开户实名账号 代冲值 优惠多多 微信号:monov8 飞机:@monov6

问题

由于众所周知的原因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.org

BUILD 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_HOST
        String 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
在这里插入图片描述
自取去设置环境变量别懒得一坨耙耙一样了

阿里云国内75折 回扣 微信号:monov8
阿里云国际,腾讯云国际,低至75折。AWS 93折 免费开户实名账号 代冲值 优惠多多 微信号:monov8 飞机:@monov6