Finished with error: Gradle task assembleDebug failed with exit code 1

本文讲述了在使用Flutter进行应用开发过程中遇到的一个打包错误:Gradle任务assembleDebug失败的问题及解决方法。作者通过排查Git提交记录发现了一个错误的导入语句,最终成功解决了该问题。

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

最近在使用flutter 开发的过程中遇到如下bug:

在run的过程中,报

Finished with error: Gradle task assembleDebug failed with exit code 1

这个时候如果比较着急打包给别人用的话,可以用flutter clean ,然后重新run,第一次总是能成功的,

然后,第一次后继续run,后面就会继续有这个错误。

 

总不能一直flutter clean ,然后再run吧,那样太浪费时间了,不是长久之计。

-----------------------------------------------

 

根据上面那行错误信息google一番遇到类似的情况的倒是很多,但是错误原因却各不相同,并且我也没有看到有可能

是和我遇到的这种情况相同原因的可能性,

---------------------

但是有回答说运行 flutter run -v 可以获得错误更为详细的信息,然而还是没什么卵用。

根据flutter run -v 获得的信息并不能定位错误原因。

 

flutter做为一个新的跨平台方案真的步步为坑啊,但是问题总是要解决,项目也要继续做,

--------------

于是开始思索,截止前天下班还是没有这种情况,昨天从中午开始就有了这种问题,那么

是否可以从git的提交记录中找到线索?

--------------------------------

于是开始仔细看这段时间的Git提交记录,找到一行可疑的

import 'package:inin/features/searchpage/SearchUserPage.dart%20';

后面多了个%20 ,是否是这个原因导致的呢?

------------------------

于是,删除这行,flutter clean , 重新run, 问题终于不再出现。

破案了。。。

 

 

"D:\xiaochengxuyunkaifa\DevEco Studio\tools\node\node.exe" "D:\xiaochengxuyunkaifa\DevEco Studio\tools\hvigor\bin\hvigorw.js" --mode module -p module=entry@default -p product=default -p pageType=page -p compileResInc=true -p requiredDeviceType=phone -p previewMode=true -p buildRoot=.preview PreviewBuild --watch --analyze=normal --parallel --incremental --daemon > hvigor UP-TO-DATE :entry:default@PreBuild... > hvigor UP-TO-DATE :entry:default@MergeProfile... > hvigor UP-TO-DATE :entry:default@CreateBuildProfile... > hvigor Finished :entry:default@PreCheckSyscap... after 1 ms > hvigor UP-TO-DATE :entry:default@GeneratePkgContextInfo... > hvigor UP-TO-DATE :entry:default@ProcessProfile... > hvigor UP-TO-DATE :entry:default@ProcessRouterMap... > hvigor Finished :entry:default@PreviewProcessResource... after 1 ms > hvigor UP-TO-DATE :entry:default@GenerateLoaderJson... > hvigor UP-TO-DATE :entry:default@PreviewCompileResource... > hvigor Finished :entry:default@PreviewHookCompileResource... after 1 ms > hvigor UP-TO-DATE :entry:default@CopyPreviewProfile... > hvigor Finished :entry:default@ReplacePreviewerPage... after 1 ms > hvigor Finished :entry:buildPreviewerResource... after 1 ms > hvigor UP-TO-DATE :entry:default@PreviewUpdateAssets... > hvigor ERROR: Failed :entry:default@PreviewArkTS... > hvigor ERROR: ArkTS:ERROR File: D:/wodePROJECT/entry/src/main/ets/pages/Index.ets:31:18 Unknown resource name 'icon_scan'.ArkTS:ERROR File: D:/wodePROJECT/entry/src/main/ets/pages/Index.ets:42:18 Unknown resource name 'home_banner'. > hvigor ERROR: BUILD FAILED in 8 s 101 ms Process finished with exit code -1
05-30
PS D:\face\r\android> yarn example android info A dev server is already running for this project on port 8082. info Installing the app... > Configure project :react-native-nitro-inspire-faceplugin:compileKotlin [NitroModules] ? nitroinspireface is boosted by nitro! > Configure project :react-native-nitro-modules [NitroModules] ? Your app is boosted by nitro modules! [Incubating] Problems report is available at: file:///D:/face/r/example/android/build/reports/problems/problems-report.html Deprecated Gradle features were used in this build, making it incompatible with Gradle 9.0. You can use '--warning-mode all' to show the individual deprecation warnings and determine if they come from your own scripts or plugins. For more on this, please refer to https://docs.gradle.org/8.12/userguide/command_line_interface.html#sec:command_line_warnings in the Gradle documentation. 10 actionable tasks: 10 executed info 💡 Tip: Make sure that you have set up your development environment correctly, by running npx react-native doctor. To read more about doctor command visit: https://github.com/react-native-community/cli/blob/main/packages/cli-doctor/README.md#doctor FAILURE: Build failed with an exception. * Where: Build file 'D:\face\r\example\node_modules\react-native-reanimated\android\build.gradle' line: 53 * What went wrong: A problem occurred evaluating project ':react-native-reanimated'. > Process 'command 'node'' finished with non-zero exit value 1 * 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 1m 7s error Failed to install the app. Command failed with exit code 1: gradlew.bat app:installDebug -PreactNativeDevServerPort=8082 FAILURE: Build failed with an exception. * Where: Build file 'D:\face\r\example\node_modules\react-native-reanimated\android\build.gradle' line: 53 * What went wrong: A problem occurred evaluating project ':react-native-reanimated'. > Process 'command 'node'' finished with non-zero exit value 1 * 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 1m 7s.
07-31
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值