question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Using "args" in launch.json for an attach request reports an error

See original GitHub issue

Describe the bug

When trying to attach the debugger to a flutter app I get the error message:

There are multiple observatory ports available.
Rerun this command with one of the following passed in as the appId:

  flutter attach --app-id com.example.myApp
  flutter attach --app-id com.example.myApp (2)

However, there is no configuration option available for type dart in the launch.json for me to be able to specify app-id

My launch.json looks like this:

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "debug app",
            "request": "attach",
            "type": "dart",
            "deviceId": "51ABDF9C-C54D-4811-BBDA-E733639AEC51",
        },
    ]
}

To Reproduce Steps to reproduce the behavior:

  1. Run an app in the terminal with flutter run
  2. Run the debug app launch config specified above.

I’ve also tried not launching with flutter run by just tapping on the app in the emulator and then trying to attach but the same problem occurs.

Expected behavior

I expected to be able to attach to the running process.

Versions (please complete the following information):

  • VS Code version: 1.57.1
  • Dart extension version: 3.23.1
  • Dart/Flutter SDK version: Flutter 2.2.1, Dart 2.13.1

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
ksilzcommented, Aug 14, 2021

I had the same thing happening when debugging a Flutter app on iOS in IntelliJ. Adding --app-id com.yourhomeingoodhands.mobile.yhigh in the “Additional attach args” field of the “Run/Debug Configuration” of my Flutter app fixed it. That was suggested by somebody in the forum.

2reactions
DanTupcommented, Jun 25, 2021

Thanks - I suspected that might be the case as I was updating the title - if I remember correctly they have their own definitions. There’s probably not been much reason to use args in attach before this, so may have been left off intentionally, but this seems like good reason to change it - we shouldn’t report errors on settings that actually change behaviour.

Thanks!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Configure launch.json for C/C++ debugging in Visual Studio ...
Specifies the full path to the executable the debugger will launch or attach to. The debugger requires this location in order to load...
Read more >
In Visual Studio Code, how to pass arguments in launch.json
As described in the documentation, you need to use the args attribute. E.g. { // Use IntelliSense to learn about possible attributes.
Read more >
Starting a Debug Session — Gaudi Documentation
You can either start the TPC test program manually and request Visual Studio Code to attach to it, or you can request Visual...
Read more >
Launch Configuration - Dart Code - Dart & Flutter support for ...
A launch configuration ( .vscode/launch.json ) file is not required for the most common use cases for Dart/Flutter as long as you stick...
Read more >
Debugging - Business Central | Microsoft Learn
Debugging is the process of finding and correcting errors. ... You can set a breakpoint by using the Debug Menu in Visual Studio...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found