Last night, I tried to update my Flutter SDK from 3.27.2 to 3.29.0.
I got an exception telling me that it couldn't upgrade Flutter SDK because there's another program using it (apology to not bring up here the actual logs).
I eventually closed the VS Code and restarted it because I thought it resolved the issue.
Upon VS Code restart, I then execute the flutter upgrade
on the terminal, and it won't respond, but instead shows a notification:
Initializing the Flutter SDK. This may take a few minutes.
Fast-forward until after my machine was rebooted already... The issue persists.
I already browsed through other relevant questions in other SO posts with these links:
They do not provide any relevant information regarding their issues, what only related to my case is this notification message:
Initializing the Flutter SDK. This may take a few minutes.
I've waited for hours hoping it would eventually be completed in initializing Flutter SDK to VS Code.
I observed that it produces iterative printing of information about the process. Furthermore, I suspected it is related and could be used as a guideline in troubleshooting.
This is what prints on the OUTPUT
tab:
Error: Unable to create dart snapshot for flutter tool. Building flutter tool... Running pub upgrade... Resolving dependencies... Downloading packages... Got dependencies. evacuation failed evacuation failed evacuation failed Exhausted heap space, trying to allocate 488976 bytes. Crash when compiling package:_macros/src/executor/introspection_impls.dart: Out of Memory
#0 _StringBase._concatRangeNative (dart:core-patch/string_patch.dart:1031:78) #1 _JsonStringStringifier.stringify (dart:convert/json.dart:1006:19) #2 LibraryProblemReporting.addProblem (package:front_end/src/base/messages.dart:75:33) #3 SourceLoader.tokenize (package:front_end/src/source/source_loader.dart:1098:25) #4 _rootRunUnary (dart:async/zone.dart:1538:47) #5 _FutureListener.handleValue (dart:async/future_impl.dart:208:18) #6 Future._propagateToListeners.handleValueCallback (dart:async/future_impl.dart:932:45) #7 Future._propagateToListeners (dart:async/future_impl.dart:961:13) #8 Future._completeWithValue (dart:async/future_impl.dart:712:5) #9 Future._asyncCompleteWithValue. (dart:async/future_impl.dart:792:7) #10 _rootRun (dart:async/zone.dart:1525:13) #11 _CustomZone.run (dart:async/zone.dart:1422:19) #12 _CustomZone.bindCallback. (dart:async/zone.dart:1345:23) #13 _microtaskLoop (dart:async/schedule_microtask.dart:40:21) #14 _startMicrotaskLoop (dart:async/schedule_microtask.dart:49:5) #15 _runPendingImmediateCallback (dart:isolate-patch/isolate_patch.dart:128:13) #16 _Timer._runTimers (dart:isolate-patch/timer_impl.dart:417:11) #17 _Timer._handleMessage (dart:isolate-patch/timer_impl.dart:441:5) #18 _RawReceivePort._handleMessage (dart:isolate-patch/isolate_patch.dart:194:12)
Error: Unable to create dart snapshot for flutter tool. Building flutter tool... Running pub upgrade... Resolving dependencies... Downloading packages... Got dependencies. evacuation failed Exhausted heap space, trying to allocate 488976 bytes. Crash when compiling package:_macros/src/executor/introspection_impls.dart: Out of Memory
#0 _StringBase._concatRangeNative (dart:core-patch/string_patch.dart:1031:78) #1 _JsonStringStringifier.stringify (dart:convert/json.dart:1006:19) #2 LibraryProblemReporting.addProblem (package:front_end/src/base/messages.dart:75:33) #3 SourceLoader.tokenize (package:front_end/src/source/source_loader.dart:1098:25) #4 _rootRunUnary (dart:async/zone.dart:1538:47) #5 _FutureListener.handleValue (dart:async/future_impl.dart:208:18) #6 Future._propagateToListeners.handleValueCallback (dart:async/future_impl.dart:932:45) #7 Future._propagateToListeners (dart:async/future_impl.dart:961:13) #8 Future._completeWithValue (dart:async/future_impl.dart:712:5) #9 Future._asyncCompleteWithValue. (dart:async/future_impl.dart:792:7) #10 _rootRun (dart:async/zone.dart:1525:13) #11 _CustomZone.run (dart:async/zone.dart:1422:19) #12 _CustomZone.bindCallback. (dart:async/zone.dart:1345:23) #13 _microtaskLoop (dart:async/schedule_microtask.dart:40:21) #14 _startMicrotaskLoop (dart:async/schedule_microtask.dart:49:5) #15 _runPendingImmediateCallback (dart:isolate-patch/isolate_patch.dart:128:13) #16 _Timer._runTimers (dart:isolate-patch/timer_impl.dart:417:11) #17 _Timer._handleMessage (dart:isolate-patch/timer_impl.dart:441:5) #18 _RawReceivePort._handleMessage (dart:isolate-patch/isolate_patch.dart:194:12)
Error: Unable to create dart snapshot for flutter tool. Building flutter tool... Running pub upgrade... Resolving dependencies... Downloading packages... Got dependencies.
I deliberately include the redundant duplicate output, which serves as a piece of evidence that it's occurring iteratively.
I have no idea to deal with it since I installed Flutter before with this tutorial Use VS Code to install Flutter.
However, when I tried to execute flutter doctor
.
The logs print this:
Building flutter tool... Running pub upgrade... Resolving dependencies... (2.6s) Downloading packages... Got dependencies. evacuation failed evacuation failed Exhausted heap space, trying to allocate 488976 bytes. Crash when compiling package:_macros/src/executor/introspection_impls.dart: Out of Memory
#0 _StringBase._concatRangeNative (dart:core-patch/string_patch.dart:1031:78) #1 _JsonStringStringifier.stringify (dart:convert/json.dart:1006:19) #2 LibraryProblemReporting.addProblem (package:front_end/src/base/messages.dart:75:33) #3 SourceLoader.tokenize (package:front_end/src/source/source_loader.dart:1098:25) #4 _rootRunUnary (dart:async/zone.dart:1538:47) #5 _FutureListener.handleValue (dart:async/future_impl.dart:208:18) #6 Future._propagateToListeners.handleValueCallback (dart:async/future_impl.dart:932:45) #7 Future._propagateToListeners (dart:async/future_impl.dart:961:13) #8 Future._completeWithValue (dart:async/future_impl.dart:712:5) #9 Future._asyncCompleteWithValue. (dart:async/future_impl.dart:792:7) #10 _rootRun (dart:async/zone.dart:1525:13) #11 _CustomZone.run (dart:async/zone.dart:1422:19) #12 _CustomZone.bindCallback. (dart:async/zone.dart:1345:23) #13 _microtaskLoop (dart:async/schedule_microtask.dart:40:21) #14 _startMicrotaskLoop (dart:async/schedule_microtask.dart:49:5) #15 _runPendingImmediateCallback (dart:isolate-patch/isolate_patch.dart:128:13) #16 _Timer._runTimers (dart:isolate-patch/timer_impl.dart:417:11) #17 _Timer._handleMessage (dart:isolate-patch/timer_impl.dart:441:5) #18 _RawReceivePort._handleMessage (dart:isolate-patch/isolate_patch.dart:194:12)
Error: Unable to create dart snapshot for flutter tool.
These are the workarounds I've gone through to finally resolve the issue: With a reference from this question thread and a working solution from this answer thread.
By removing the Flutter SDK, wondering if it might be corrupted due to the unusual consumption of memory.
The shortcut solution, or to summarize, the solution is to uninstall Flutter 3.27.2 (the path of the Flutter SDK where it is located). Then reinstall the stable Flutter SDK of Flutter 3.27.2 from: Install the Flutter by following the Download and Install tab > SDK Archive > Stable Channel > Windows > 3.27.2.
After I successfully and properly reinstalled Flutter 3.27.2 through Windows PowerShell. Instead of running the command flutter upgrade
directly in the VS Code terminal, I decided to only run this in Windows PowerShell.
Here's the actual terminal upgrading process:
PS C:\Users\myUserPath> flutter upgrade
Upgrading Flutter to 3.29.0 from 3.27.2 in C:\Users\myUserPath\FlutterSDK\flutter... Checking Dart SDK version... Downloading Dart SDK from Flutter engine f73bfc4522dd0bc87bbcdb4bb3088082755c5e87... Downloading the Dart SDK using the BITS service failed, retrying with WebRequest... Expanding downloaded archive with PowerShell... Building flutter tool... Running pub upgrade... Resolving dependencies... Downloading packages... Got dependencies.
Upgrading engine... Downloading android-arm-profile/windows-x64 tools... 1,095ms Downloading android-arm-release/windows-x64 tools... 308ms Downloading android-arm64-profile/windows-x64 tools...
296ms Downloading android-arm64-release/windows-x64 tools...
234ms Downloading android-x64-profile/windows-x64 tools...
243ms Downloading android-x64-release/windows-x64 tools...
308ms Downloading android-x86 tools...
2,257ms Downloading android-x64 tools...
2,033ms Downloading android-arm tools...
101.4s Downloading android-arm-profile tools... 78.1s Downloading android-arm-release tools... 828ms Downloading android-arm64 tools...
3.1s Downloading android-arm64-profile tools... 591ms Downloading android-arm64-release tools...
430ms Downloading android-x64-profile tools...
614ms Downloading android-x64-release tools...
657ms Downloading Web SDK...
79.2s Downloading package sky_engine... 188ms Downloading package flutter_gpu...
69ms Downloading flutter_patched_sdk tools...
386ms Downloading flutter_patched_sdk_product tools...
242ms Downloading windows-x64 tools...
2,718ms Downloading windows-x64-debug/windows-x64-flutter tools...
6.8s Downloading windows-x64/flutter-cpp-client-wrapper tools... 19.2s Downloading windows-x64/flutter-cpp-client-wrapper tools... 356ms Downloading windows-x64-profile/windows-x64-flutter tools...
6.0s Downloading windows-x64-release/windows-x64-flutter tools... 4.0s Downloading windows-x64/font-subset tools... 187msFlutter 3.29.0 • channel stable • https://github.com/flutter/flutter.git Framework • revision 35c388afb5 (3 weeks ago) • 2025-02-10 12:48:41 -0800 Engine • revision f73bfc4522 Tools • Dart 3.7.0 • DevTools 2.42.2
Running flutter doctor... Doctor summary (to see all details, run flutter doctor -v): [√] Flutter (Channel stable, 3.29.0, on Microsoft Windows [Version 10.0.26100.3194], locale en-US) [√] Windows Version (11 Home Single Language 64-bit, 24H2, 2009) [√] Android toolchain - develop for Android devices (Android SDK version 35.0.0) [√] Chrome - develop for the web [√] Visual Studio - develop Windows apps (Visual Studio Build Tools 2019 16.11.37) [√] Android Studio (version 2024.2) [√] VS Code (version 1.97.2) [√] Connected device (3 available) [√] Network resources
• No issues found!
I hope it helps future readers!