解决 Flutter assemble 长时间卡死后失败问题

软件环境

Flutter 3.19.5 • channel stable • https://github.com/flutter/flutter.git
Framework • revision 300451adae (2 weeks ago) • 2024-03-27 21:54:07 -0500
Engine • revision e76c956498
Tools • Dart 3.3.3 • DevTools 2.31.1

解决方法

需要修改项目中两个文件:

  • gradle/wrapper/gradle-wrapper.properties
  • build.gradle (注意:不是 app/build.gradle)

分别修改这两个文件内的 distributionUrl 路径和仓库地址。

修改 gradle/wrapper/gradle-wrapper.properties

distributionUrl=https\://services.gradle.org/distributions/gradle-x.x.x-all.zip​ 修改为 distributionUrl=https\://mirrors.cloud.tencent.com/gradle/gradle-x.x.x-all.zip​。

也就是将 gradle url 的部分路径 https\://services.gradle.org/distributions/​ 修改为 https\://mirrors.cloud.tencent.com/gradle/​。

以 gradle-7.6.3-all.zip 为例,distributionUrl 修改后的结果如下:

distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists

#distributionUrl=https\://services.gradle.org/distributions/gradle-7.6.3-all.zip
distributionUrl=https\://mirrors.cloud.tencent.com/gradle/gradle-7.6.3-all.zip
修改 build.gradle

repositories​ 添加阿里仓库:

maven{ url 'https://maven.aliyun.com/repository/google'}
maven{ url 'https://maven.aliyun.com/repository/gradle-plugin'}
maven{ url 'https://maven.aliyun.com/repository/public'}
maven{ url 'https://maven.aliyun.com/repository/jcenter'}

修改后的结果:

allprojects {        
    repositories {        
        maven{ url 'https://maven.aliyun.com/repository/google'}
        maven{ url 'https://maven.aliyun.com/repository/gradle-plugin'}
        maven{ url 'https://maven.aliyun.com/repository/public'}
        maven{ url 'https://maven.aliyun.com/repository/jcenter'}
        google()        
        mavenCentral()        
    }
}

参考文章

https://blog.csdn.net/afunx/article/details/129913028

结束语

本文如有偏颇,恳请斧正。

  • 4
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值