Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unable to debug flutter dart code in VS Code, Unverified Breakpoint error

files structureWhen the code is not running, I can add breakpoint (round red circle), but as soon as it goes into debug mode, it turns into unverified breakpoint (grey hollow circle) and doesn't work at all. However, the same project works well on other systems. I've no idea what the problem is or what the solution would be. I've tried reinstalling flutter SDK numerous times, and have gone through a lot of links on SOF and GitHub regarding this, but none has been helpful enough.

Environment - VS Code, Flutter version: 1.17.2

Flutter doctor -

[✓] Flutter (Channel stable, v1.17.2, on Mac OS X 10.15.3 19D76, locale en-GB)
[✗] Android toolchain - develop for Android devices
    ✗ Unable to locate Android SDK.
      Install Android Studio from: https://developer.android.com/studio/index.html
      On first launch it will assist you in installing the Android SDK components.
      (or visit https://flutter.dev/docs/get-started/install/macos#android-setup for detailed instructions).
      If the Android SDK has been installed to a custom location, set ANDROID_SDK_ROOT to that location.
      You may also want to add it to your PATH environment variable.

[✓] Xcode - develop for iOS and macOS (Xcode 11.3.1)
[!] Android Studio (not installed)
[✓] VS Code (version 1.45.1)
[✓] Connected device (1 available)

! Doctor found issues in 2 categories.

My launch.json File -

{
    // Use IntelliSense to learn about possible attributes.
    // Hover to view descriptions of existing attributes.
    // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Flutter: Run all Tests",
            "type": "dart",
            "request": "launch",
            "program": "./test/"
        },
        {
            "name": "Dart: Run all Tests",
            "type": "dart",
            "request": "launch",
            "program": "./test/"
        },
        {
            "name": "Dart",
            "type": "dart",
            "request": "launch",
            "program": "bin/main.dart"
        },
    {
        "name": "Dart: Attach to Process",
        "type": "dart",
        "request": "attach"
    },
        {
            "name": "Flutter",
            "request": "launch",
            "type": "dart"
        }
    ]
}

Also, If you know any good alternatives to VSCode and Android Studio for Flutter, please share.

like image 944
Shishir Avatar asked Jun 04 '20 18:06

Shishir


3 Answers

i came from mac and always use fn + f5, on windows that means start withouth debugggin, that was my mistake.

like image 78
Rodrigo porras Avatar answered Oct 18 '22 22:10

Rodrigo porras


 "version": "0.2.0",
  "configurations": [
    {
      "name": "Flutter",
      "request": "launch",
      "type": "dart",
      "flutterMode": "debug"
    }
  ]
}

This is my launch.json file ... changing "flutterMode" from profile to debug solved the issue ... if you dont have this line adding it could help.

like image 42
boris_dv Avatar answered Oct 18 '22 22:10

boris_dv


Clicking Run on the top menu in VS code and selecting 'Enable all breakpoints' worked for me. Though you have to place your breakpoint first.

You can also try placing your breakpoint and save your code, then leave the emulator running and close and restart your vs code IDE and run the app with debugging.

like image 5
Edmond Avatar answered Oct 18 '22 20:10

Edmond