学习Flutter 编译配置运行遇到的坑

本文详细描述了在使用Flutter进行应用开发时,遇到的关于资源压缩配置导致的运行错误。具体表现为在运行程序时,Gradle构建失败,提示移除无用资源需开启代码瘦身。文章提供了具体的错误信息及解决步骤,包括禁用内存对齐和移除无用的resource文件,以帮助开发者快速定位并解决问题。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

在flutter run  运行程序是出现如下错误,当时蛋疼的一B,查了一下原来是设置了删除无用资源导致的。

* Error running Gradle:
ProcessException: Process "/Users/Na/Desktop/dd/FlutterProject/flutter_http/android/gradlew" exited abnormally:

FAILURE: Build failed with an exception.

* Where:
Build file '/Users/NN/Desktop/NN/FlutterProject/flutter_http/android/build.gradle' line: 34

* What went wrong:
A problem occurred evaluating root project 'android'.
> A problem occurred configuring project ':app'.
   > Removing unused resources requires unused code shrinking to be turned on. See http://d.android.com/r/tools/shrink-resources.html for more information.

* 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
 

解决办法删除以下两项再次运行解决上述问题。

zipAlignEnabled true//内存对齐
// 移除无用的resource文件
shrinkResources true

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值