Dart-Code: Unable to select devices or start debugging Flutter apps
Describe the bug
I can’t debug my Flutter app using VSCode anymore. When I start VSCode, it shows ‘No Device’ in the bottom right corner and interacting with it does not give me any options for devices. Trying to run a debug session with F5 or by clicking ‘Run and debug’ creates a loop and the debugger never starts.
To Reproduce
I am unable to reproduce it since it is still occurring.
Workspace
- Operating System and version: “Windows 10 Pro” 10.0 (Build 22631)
- VS Code version: win 1.84.2
- Dart extension version: 3.76.1
- Flutter extension version: 3.76.0
- Dart/Flutter SDK version: Dart (3.1.5) / Flutter (3.13.9)
Steps I Tried to Solve the Problem
- Initializing the app through ‘flutter run’ (it works; the terminal gives me the correct options for available devices, but – as far as I know, at least – you can’t do a step-by-step debug from it, only through IDEs).
- Running ‘flutter doctor’ (everything is okay)
- Creating a new project and attempting to debug it.
- Disabling and, also, uninstalling all my extensions (leaving only Dart and Flutter extensions).
- Uninstalling VSCode (and reinstalling after a reboot).
- Uninstalling Flutter/Dart (and reinstalling after a reboot).
- Uninstalling both VSCode and Flutter/Dart (and reinstalling after a reboot), also completely cleaning any residual files before reinstalling too.
- Rolling back extensions to an older version (that I had used before).
- Deleting and rebuilding the launch.json file (by using VSCode’s default option to create a launch.json file).
- Deleting my entire project and cloning it again using Git in another directory.
- Creating a new project in another directory.
LOG flutter doctor -v
PS C:\Users\PcUser\Documents\Projects\FlutterApp> flutter doctor -v
[√] Flutter (Channel stable, 3.13.9, on Microsoft Windows [versÆo 10.0.22631.2506], locale pt-BR)
• Flutter version 3.13.9 on channel stable at C:\Flutter\flutter
• Upstream repository unknown source
• FLUTTER_GIT_URL = unknown source
• Framework revision d211f42860 (3 weeks ago), 2023-10-25 13:42:25 -0700
• Engine revision 0545f8705d
• Dart version 3.1.5
• DevTools version 2.25.0
[√] Windows Version (Installed version of Windows is version 10 or higher)
[√] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
• Android SDK at C:\Users\PcUser\AppData\Local\Android\Sdk
• Platform android-34, build-tools 34.0.0
• ANDROID_HOME = C:\Users\PcUser\AppData\Local\Android\Sdk
• Java binary at: C:\Program Files\Android\Android Studio\jbr\bin\java
• Java version OpenJDK Runtime Environment (build 17.0.6+0-b2043.56-9586694)
• All Android licenses accepted.
[√] Chrome - develop for the web
• Chrome at C:\Program Files\Google\Chrome\Application\chrome.exe
[√] Visual Studio - develop Windows apps (Visual Studio Community 2022 17.6.3)
• Visual Studio at C:\Program Files\Microsoft Visual Studio\2022\Community
• Visual Studio Community 2022 version 17.6.33801.468
• Windows 10 SDK version 10.0.22000.0
[√] Android Studio (version 2022.2)
• Android Studio at C:\Program Files\Android\Android Studio
• Flutter plugin can be installed from:
https://plugins.jetbrains.com/plugin/9212-flutter
• Dart plugin can be installed from:
https://plugins.jetbrains.com/plugin/6351-dart
• Java version OpenJDK Runtime Environment (build 17.0.6+0-b2043.56-9586694)
[√] VS Code (version 1.84.2)
• VS Code at C:\Users\PcUser\AppData\Local\Programs\Microsoft VS Code
• Flutter extension version 3.70.0
[√] Connected device (3 available)
• Windows (desktop) • windows • windows-x64 • Microsoft Windows [versÆo 10.0.22631.2506]
• Chrome (web) • chrome • web-javascript • Google Chrome 119.0.6045.124
• Edge (web) • edge • web-javascript • Microsoft Edge 119.0.2151.58
[√] Network resources
• All expected network resources are available.
• No issues found!
Edit: The ‘Returning cached promise for getSupportedPlatforms()’ lines are me clicking the ‘No Device’ button in the bottom right corner of VSCode. After that I try running the debugger with F5 and then by clicking ‘Run and Debug’
Dart Capture LOG 1 (About a minute) - Older versions of extensions
Dart Code extension: 3.70.0
Flutter extension: 3.70.0 (activated)
App: Visual Studio Code
Version: 1.84.2
Platform: win
Workspace type: Flutter
Analyzer type: LSP
Multi-root?: false
Dart SDK:
Loc: C:\Flutter\flutter\bin\cache\dart-sdk
Ver: 3.1.5
Flutter SDK:
Loc: C:\Flutter\flutter
Ver: 3.13.9
HTTP_PROXY: undefined
NO_PROXY: undefined
Logging Categories:
General, CommandProcesses, DartTest, DAP, VmService, DevTools, FlutterDaemon, FlutterRun, FlutterTest, WebDaemon
Wed Nov 15 2023 Log file started
[8:51:48 AM] [General] [Info] Returning cached results for project search
[8:51:50 AM] [General] [Info] Returning cached results for project search
[8:51:50 AM] [General] [Info] Checking 1 projects for supported platforms
[8:51:50 AM] [FlutterDaemon] [Info] ==> [{"id":"3","method":"daemon.getSupportedPlatforms","params":{"projectRoot":"C:\\Users\\PcUser\\Documents\\Projects\\FlutterApp"}}]
[8:51:50 AM] [General] [Info] Returning cached promise for getSupportedPlatforms()
[8:51:51 AM] [General] [Info] Returning cached promise for getSupportedPlatforms()
[8:51:51 AM] [General] [Info] Returning cached promise for getSupportedPlatforms()
[8:51:51 AM] [General] [Info] Returning cached promise for getSupportedPlatforms()
[8:51:51 AM] [General] [Info] Returning cached promise for getSupportedPlatforms()
[8:51:51 AM] [General] [Info] Returning cached promise for getSupportedPlatforms()
[8:51:52 AM] [General] [Info] Returning cached promise for getSupportedPlatforms()
[8:51:52 AM] [General] [Info] Returning cached promise for getSupportedPlatforms()
[8:51:53 AM] [General] [Info] Returning cached promise for getSupportedPlatforms()
[8:51:54 AM] [General] [Info] Returning cached promise for getSupportedPlatforms()
[8:51:55 AM] [General] [Info] Returning cached promise for getSupportedPlatforms()
[8:51:56 AM] [General] [Info] Returning cached promise for getSupportedPlatforms()
[8:51:57 AM] [General] [Info] Returning cached promise for getSupportedPlatforms()
[8:52:04 AM] [General] [Info] Starting debug session...
[8:52:04 AM] [General] [Info] workspace: C:\\Users\\PcUser\\Documents\\Projects\\FlutterApp
[8:52:04 AM] [General] [Info] Setting cwd based on likely entry point: C:\\Users\\<PcUser>\\Documents\\<Projects>\\<FlutterApp>
[8:52:04 AM] [General] [Info] Using open file as entry point: C:\\Users\\PcUser\\Documents\\Projects\\FlutterApp\\lib\\main.dart
[8:52:04 AM] [General] [Info] Using workspace as cwd: C:\\Users\\<PcUser>\\Documents\\<Projects>\\<FlutterApp>
[8:52:04 AM] [General] [Info] Detected launch project as Flutter
[8:52:04 AM] [General] [Info] Using Flutter debug adapter for this session
[8:52:04 AM] [FlutterDaemon] [Info] ==> [{"id":"4","method":"daemon.getSupportedPlatforms","params":{"projectRoot":"C:\\Users\\PcUser\\Documents\\Projects\\FlutterApp"}}]
[8:52:09 AM] [General] [Info] Returning cached promise for getSupportedPlatforms()
Wed Nov 15 2023 Log file ended
Dart Capture LOG 2 (About a minute) - Latest versions of extensions
Dart Code extension: 3.76.1
Flutter extension: 3.76.0 (activated)
App: Visual Studio Code
App Host: desktop
Version: win 1.84.2
Workspace type: Flutter (LSP)
Dart (3.1.5): C:\Flutter\flutter\bin\cache\dart-sdk
Flutter (3.13.9): C:\Flutter\flutter (No device)
Logging Categories:
General, CommandProcesses, DartTest, DAP, VmService, DevTools, FlutterDaemon, FlutterRun, FlutterTest, WebDaemon
Wed Nov 15 2023 [09:01:57 GMT-0300 (Brasilia Standard Time)] Log file started
[9:02:00 AM] [General] [Info] Returning cached results for project search
[9:02:00 AM] [General] [Info] Checking 1 projects for supported platforms
[9:02:00 AM] [FlutterDaemon] [Info] ==> [{"id":"3","method":"daemon.getSupportedPlatforms","params":{"projectRoot":"C:\\Users\\PcUser\\Documents\\Projects\\FlutterApp"}}]
[9:02:05 AM] [General] [Info] Returning cached promise for getSupportedPlatforms()
[9:02:09 AM] [General] [Info] Returning cached promise for getSupportedPlatforms()
[9:02:11 AM] [General] [Info] Returning cached promise for getSupportedPlatforms()
[9:02:14 AM] [General] [Info] Starting debug session...
[9:02:14 AM] [General] [Info] workspace: C:\Users\PcUser\Documents\Projects\FlutterApp
[9:02:14 AM] [General] [Info] Setting cwd based on likely entry point: C:\Users\PcUser\Documents\Projects\FlutterApp
[9:02:14 AM] [General] [Info] Using open file as entry point: C:\Users\PcUser\Documents\Projects\FlutterApp\lib\main.dart
[9:02:14 AM] [General] [Info] Using workspace as cwd: C:\Users\PcUser\Documents\Projects\FlutterApp
[9:02:14 AM] [General] [Info] Detected launch project as Flutter
[9:02:14 AM] [General] [Info] Using Flutter debug adapter for this session
[9:02:14 AM] [FlutterDaemon] [Info] ==> [{"id":"4","method":"daemon.getSupportedPlatforms","params":{"projectRoot":"C:\\Users\\PcUser\\Documents\\Projects\\FlutterApp"}}]
[9:02:19 AM] [General] [Info] Returning cached promise for getSupportedPlatforms()
[9:02:34 AM] [General] [Info] Starting debug session...
[9:02:34 AM] [General] [Info] workspace: C:\Users\PcUser\Documents\Projects\FlutterApp
[9:02:34 AM] [General] [Info] Setting cwd based on likely entry point: C:\Users\PcUser\Documents\Projects\FlutterApp
[9:02:34 AM] [General] [Info] Using open file as entry point: C:\Users\PcUser\Documents\Projects\FlutterApp\lib\main.dart
[9:02:34 AM] [General] [Info] Using workspace as cwd: C:\Users\PcUser\Documents\Projects\FlutterApp
[9:02:34 AM] [General] [Info] Detected launch project as Flutter
[9:02:34 AM] [General] [Info] Using Flutter debug adapter for this session
[9:02:34 AM] [FlutterDaemon] [Info] ==> [{"id":"5","method":"daemon.getSupportedPlatforms","params":{"projectRoot":"C:\\Users\\PcUser\\Documents\\Projects\\FlutterApp"}}]
[9:02:39 AM] [General] [Info] Returning cached promise for getSupportedPlatforms()
Wed Nov 15 2023 [09:03:31 GMT-0300 (Brasilia Standard Time)] Log file ended
About this issue
- Original URL
- State: open
- Created 8 months ago
- Comments: 86 (36 by maintainers)
Commits related to this issue
- Add some verbose logging to daemon See https://github.com/Dart-Code/Dart-Code/issues/4840 — committed to DanTup/flutter by DanTup 7 months ago
- Simple repro Trying to track down https://github.com/Dart-Code/Dart-Code/issues/4840 — committed to DanTup/flutter_daemon_tester by DanTup 4 months ago
Hi @DanTup,
Sorry for the delay but I was pretty busy last days. I managed to find which line brakes the script. it is in flutter\bin\internal\shared.bat
When I comment out line 46 the stdin doesn’t end at the beginning. Honestly I am not sure why this causes the problem, but hope this will help you find the root cause.