Flutter App launch doesn t work in VS Code

0 votes

I have a project with two friends, where we are building an app. We use Azure DevOps for downloading and uploading our changes and VS Code for writing the code. Whenever I run the main.dart file it says:

Set the 'program' value in your launch config (eg 'bin/main.dart') then launch again

So I set the program value in the launch.json file do bin/main.dart. I also saw some people with the same problem, that changed it to lib/main.dart. In my project it is in a lib folder, but I tried both anyway. Both gives the same result:

ProcessException: No such file or directory...

and 

Your launch config references a program that does not exist. If you have problems launching, check the "program" field in your ".vscode/launch.json" file.

Does anyone know what to do ?

Some people also deleted the .vscode folder and the launch.json file within. I did the same, however it still pops up when I run the file.

I also tried to create a new launch.json file, that didn't change anything neither.

There's no problem with flutter itself. I ran the flutter doctor multiple times and everything is working.

That's how it is at the moment: [1]: https://i.stack.imgur.com/2F5kE.png

Apr 3, 2023 in Flutter by sarit
• 1,830 points
11,767 views

1 answer to this question.

0 votes

It seems that the error message is indicating that the program specified in the launch.json file cannot be found. Here are some steps you can try:

  1. Check that the path to the main.dart file is correct. If your main.dart file is in a "lib" folder, the path should be "lib/main.dart".
  2. If the path is correct, try running the app using the "flutter run" command in the terminal instead of the VS Code launch configuration. Open a terminal in VS Code and run "flutter run".
  3. If the "flutter run" command works, there may be an issue with your launch configuration. Try creating a new launch.json file using the "Flutter: New Web/Android/iOS Launch Configuration" command in VS Code. Make sure to select the correct project and target platform.
  4. If none of the above steps work, try restarting VS Code or your computer.

Hopefully one of these steps will help you resolve the issue.

To know more, join our Flutter Certification Course today.

answered Apr 3, 2023 by Tej

Related Questions In Flutter