当我运行“flutter run”时发生了一个错误(没有错误消息)

ki1q1bka  于 2023-02-20  发布在  Flutter
关注(0)|答案(2)|浏览(140)

我使用了flutter run命令,但出现了以下错误:

Using hardware rendering with device Android SDK built for x86. If you get graphics artifacts, consider
enabling software rendering with "--enable-software-rendering".
Launching lib/main.dart on Android SDK built for x86 in debug mode...

FAILURE: Build failed with an exception.                                

* What went wrong:                                                      
java.lang.StackOverflowError (no error message)                         

* 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 1s                                                      
Running Gradle task 'assembleDebug'...                                  
Running Gradle task 'assembleDebug'... Done                         1.6s
Gradle task assembleDebug failed with exit code 1

所以我使用flutter run --verbose命令

[ +374 ms] FAILURE: Build failed with an exception.
[   +1 ms] * What went wrong:
[        ] java.lang.StackOverflowError (no error message)
[        ] * 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 987ms
[ +377 ms] Running Gradle task 'assembleDebug'... (completed in 1.6s)
[   +5 ms] "flutter run" took 2,280ms.
Gradle task assembleDebug failed with exit code 1

#0      throwToolExit (package:flutter_tools/src/base/common.dart:28:3)
#1      buildGradleApp (package:flutter_tools/src/android/gradle.dart:387:7)
#2      _asyncThenWrapperHelper.<anonymous closure> (dart:async-patch/async_patch.dart:73:64)
#3      _rootRunUnary (dart:async/zone.dart:1134:38)
#4      _CustomZone.runUnary (dart:async/zone.dart:1031:19)
#5      _FutureListener.handleValue (dart:async/future_impl.dart:139:18)
#6      Future._propagateToListeners.handleValueCallback (dart:async/future_impl.dart:680:45)
#7      Future._propagateToListeners (dart:async/future_impl.dart:709:32)
#8      Future._completeWithValue (dart:async/future_impl.dart:524:5)
#9      _AsyncAwaitCompleter.complete (dart:async-patch/async_patch.dart:32:15)
#10     _completeOnAsyncReturn (dart:async-patch/async_patch.dart:290:13)
#11     _DefaultProcessUtils.stream (package:flutter_tools/src/base/process.dart)
#12     _asyncThenWrapperHelper.<anonymous closure> (dart:async-patch/async_patch.dart:73:64)
#13     _rootRunUnary (dart:async/zone.dart:1134:38)
#14     _CustomZone.runUnary (dart:async/zone.dart:1031:19)
#15     _FutureListener.handleValue (dart:async/future_impl.dart:139:18)
#16     Future._propagateToListeners.handleValueCallback (dart:async/future_impl.dart:680:45)
#17     Future._propagateToListeners (dart:async/future_impl.dart:709:32)
#18     Future._completeWithValue (dart:async/future_impl.dart:524:5)
#19     Future._asyncComplete.<anonymous closure> (dart:async/future_impl.dart:554:7)
#20     _rootRun (dart:async/zone.dart:1126:13)
#21     _CustomZone.run (dart:async/zone.dart:1023:19)
#22     _CustomZone.runGuarded (dart:async/zone.dart:925:7)
#23     _CustomZone.bindCallbackGuarded.<anonymous closure> (dart:async/zone.dart:965:23)
#24     _microtaskLoop (dart:async/schedule_microtask.dart:43:21)
#25     _startMicrotaskLoop (dart:async/schedule_microtask.dart:52:5)
#26     _runPendingImmediateCallback (dart:isolate-patch/isolate_patch.dart:118:13)
#27     _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:175:5)

但是运行flutter analyzed的结果是No issues found! (ran in 2.6s),这是怎么回事?

bvjxkvbb

bvjxkvbb1#

flutter clean可以解决这个问题。

r7knjye2

r7knjye22#

如果flutter clean不能解决问题或只能部分解决问题,请尝试以下操作:cd android && ./gradlew clean。在我的例子中,每天早上flutter run都会抛出不同的随机错误。这些命令解决了所有问题,而不会改变任何东西。

相关问题