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


    前言

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

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

    将 buildscript.repositories 下面的

    1. //google()
    2. //mavenCentral()
    3. 注释掉,改成
    4. maven {
    5.    allowInsecureProtocol = true
    6.    url 'https://maven.aliyun.com/repository/google'
    7. }
    8. maven {
    9.    allowInsecureProtocol = true
    10.    url 'https://maven.aliyun.com/repository/jcenter'
    11. }
    12. maven {
    13.    allowInsecureProtocol = true
    14.    url 'http://maven.aliyun.com/nexus/content/groups/public'
    15. }

    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 下面的

    1. //google()
    2. //mavenCentral()
    3. 注释掉,改成
    4. maven {
    5.    allowInsecureProtocol = true
    6.    url 'https://maven.aliyun.com/repository/google'
    7. }
    8. maven {
    9.    allowInsecureProtocol = true
    10.    url 'https://maven.aliyun.com/repository/jcenter'
    11. }
    12. maven {
    13.    allowInsecureProtocol = true
    14.    url 'http://maven.aliyun.com/nexus/content/groups/public'
    15. }

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

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

  • 相关阅读:
    AI都那么发达了,我还有必要学习编程吗
    Kotlin高仿微信-第1篇-注册
    鸿蒙Cannot resolve symbol 'ResourceTable'
    docker-cli源码窥探
    SPARK数据分析
    微信小程序预览图片无法上传问题
    Mybatis的collection三层嵌套查询(验证通过)
    《爱的艺术》读书笔记
    es的数据存储结构;近实时查询原因
    北极星指标|专家建议如何有效制订NSM以驱动增长
  • 原文地址:https://blog.csdn.net/weixin_47723549/article/details/133940987