在Flutter项目开发过程中,修改了一下页面的文件名称,再次运行直接报错了,刚才还是好好的,而且怎么查找都没找到问题,报错内容如下:
Launching lib\main.dart on Mi Note 3 in debug mode...
Initializing gradle...
Resolving dependencies...
Running Gradle task 'assembleDebug'...
E:\coding\flutter\delivery\delivery\lib\page\order_page.dart were declared as an inputs, but did not exist. Check the definition of target:kernel_snapshot for errors
#0 Node.computeChanges (package:flutter_tools/src/build_system/build_system.dart:772:7)
<asynchronous suspension>
#1 _BuildInstance._invokeInternal (package:flutter_tools/src/build_system/build_system.dart:518:20)
<asynchronous suspension>
#2 _BuildInstance.invokeTarget.<anonymous closure> (package:flutter_tools/src/build_system/build_system.dart:482:35)
#3 new Future.sync (dart:async/future.dart:224:31)
#4 AsyncMemoizer.runOnce (package:async/src/async_memoizer.dart:43:45)
#5 _BuildInstance.invokeTarget (package:flutter_tools/src/build_system/build_system.dart:482:21)
<asynchronous suspension>
<asynchronous suspension>
#6 BuildSystem.build (package:flutter_tools/src/build_system/build_system.dart:420:36)
#7 _AsyncAwaitCompleter.start (dart:async-patch/async_patch.dart:43:6)
#8 BuildSystem.build (package:flutter_tools/src/build_system/build_system.dart:401:28)
#9 buildWithAssemble (package:flutter_tools/src/bundle.dart:171:48)
#10 _AsyncAwaitCompleter.start (dart:async-patch/async_patch.dart:43:6)
#11 buildWithAssemble (package:flutter_tools/src/bundle.dart:147:31)
#12 BundleBuilder.build (package:flutter_tools/src/bundle.dart:85:13)
#13 _AsyncAwaitCompleter.start (dart:async-patch/async_patch.dart:43:6)
#14 BundleBuilder.build (package:flutter_tools/src/bundle.dart:58:21)
#15 BuildBundleCommand.runCommand (package:flutter_tools/src/commands/build_bundle.dart:126:25)
#16 _AsyncAwaitCompleter.start (dart:async-patch/async_patch.dart:43:6)
#17 BuildBundleCommand.runCommand (package:flutter_tools/src/commands/build_bundle.dart:97:42)
#18 FlutterCommand.verifyThenRunCommand (package:flutter_tools/src/runner/flutter_command.dart:553:18)
#19 _asyncThenWrapperHelper.<anonymous closure> (dart:async-patch/async_patch.dart:71:64)
#20 _rootRunUnary (dart:async/zone.dart:1132:38)
#21 _CustomZone.runUnary (dart:async/zone.dart:1029:19)
#22 _FutureListener.handleValue (dart:async/future_impl.dart:137:18)
#23 Future._propagateToListeners.handleValueCallback (dart:async/future_impl.dart:678:45)
#24 Future._propagateToListeners (dart:async/future_impl.dart:707:32)
#25 Future._completeWithValue (dart:async/future_impl.dart:522:5)
#26 Future._asyncComplete.<anonymous closure> (dart:async/future_impl.dart:552:7)
#27 _rootRun (dart:async/zone.dart:1124:13)
#28 _CustomZone.run (dart:async/zone.dart:1021:19)
#29 _CustomZone.runGuarded (dart:async/zone.dart:923:7)
#30 _CustomZone.bindCallbackGuarded.<anonymous closure> (dart:async/zone.dart:963:23)
#31 _microtaskLoop (dart:async/schedule_microtask.dart:41:21)
#32 _startMicrotaskLoop (dart:async/schedule_microtask.dart:50:5)
#33 _runPendingImmediateCallback (dart:isolate-patch/isolate_patch.dart:116:13)
#34 _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:173:5)
Failed to build bundle.
FAILURE: Build failed with an exception.
* Where:
Script 'D:\setup\flutterSDK\flutter\packages\flutter_tools\gradle\flutter.gradle' line: 787
* What went wrong:
Execution failed for task ':app:compileFlutterBuildDebugArm64'.
> Process 'command 'D:\setup\flutterSDK\flutter\bin\flutter.bat'' 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 8s
Finished with error: Gradle task assembleDebug failed with exit code 1
根据报错内容“order_page.dart were declared as an inputs, but did not exist. Check the definition of target:kernel_snapshot for errors”提示,发现由于文件名称修改导致的,order_page.dart是原来的文件名称,已经修改为home_order_page.dart了,由于flutter编译耗时,第一次编译成功后会生成一些快照供之后编译速度的优化,但是修改了文件名称后可能快照没有自动更新导致的,找到问题了就好办了,清空一下快照缓存就可以了,具体操作如下:
打开AndroidStudio 的Terminal 窗口,输入 flutter clean 按回车,再次编译运行成功