Flutter unable to debug macos app with debugger (Flutter Attach) - flutter

I am trying to debug macos app in IntelliJ IDEA IDE and after i click "Flutter Attach" option I see only:
Waiting for a connection from Flutter on macOS...
which never changes.
Is it possible to debug macos application in IntelliJ?

Attaching to a desktop Flutter application requires attaching via observatory URL, which IntelliJ doesn't currently support. However, if you run your project from IntelliJ, rather than launching it seperately and then trying to attach, debugging should work normally.

Related

Flutter app stopped working on emulator/simulator (Windows 10 and MacOS)

My flutter project runs on real devices with F5 or with
flutter run --release
on real devices connected to the PC. It also worked on emulators (Windows 10) and simulators (macOS) but it stopped, getting an endless loading screen right after splash screen. On iOS i got this message in the logs:
PET daemon has launched
Failed to initialize PET service. Exiting...
Failed to initialize the tracker
Anyone an idea?
Try these three one by one:
1- flutter clean , flutter doctor (then resolve if there are any errors)
2- Search for dart.flutterAdditionalArgs in your vs code settings.
and remove args against it.
3- go to Android Studio , Uninstall all the sdk tools you have installed ,then reinstall it
I found the issue. It was the internet connection. Tried another one and it works.

How do I remove devices for running Flutter?

I tried creating a new flutter project in Visual Studio Code, but for whatever reason it now has a default device of Google Chrome every time I try to run it. I don't want to run Flutter in web environments whatsoever: is there any way I can disable this?
Run the following command to disable web completely.
flutter config --no-enable-web
Then restart your editor if necessary.
First, run your emulator from the AVD manager or connect your physical device while it's on debugging mode, if it's an android device, then choose the device you want to run from the flutter device selection option

How can I debug Flutter apps on Chrome and have Android Studio stop at breakpoints?

If I press Ctrl+Enter, Shift+F9 or Shift+F10, or go to Run > Run 'main.dart' or Run > Debug 'main.dart', Android Studio tries to run or debug my app on my android device, if connected, or else reports 'No connected devices...'. Debug behaves as expected, stopping at breakpoints.
('No connected devices' is already strange, as flutter devices returns that both android and Chrome devices are connected and flutter doctor returns no issues. Flutter web is enabled.)
If I go to terminal in Android Studio, I can execute flutter run -d chrome, and the app runs in 'debug mode' on Chrome. This debug mode, however, does not stop at breakpoints or behave in any obviously different way to if the app were simply run.
How can I run flutter apps on Chrome and have Android Studio stop at breakpoints?
To ensure that Android Studio is able to see the Chrome to run the project as a web app, you can select the Chrome from the list of devices dropdown - highlighted in a rectangle in the picture. You can also run the app in debug mode by clicking on the shortcut button from the toolbar - highlighted in circle.
I'm currently running Flutter plugin version 71.2.3 and the breakpoints works as expected. Dart plugin is on version 213.7433

Attempting to connect to browser instance.. (Flutter Web)

I'm trying to run my first flutter code on the web. I followed setup instructions provided in Building a web application with Flutter and created a very simple app, that's only supposed to display a navigation bar. Now as I'm running my application for the first time on "Chrome (web)" device, it won't connect to the browser. It's been almost 20 minutes and it's still telling me "Attempting to connect to browser instance".
> flutter run -d chrome
Launching lib\main.dart on Chrome in debug mode...
Building application for the web... 1215.1s
Attempting to connect to browser instance..
(This is taking an unexpectedly long time.)
Can anyone guide me on how to fix this?
In my case, I couldn't disable the virus guard. So I used the server mode.
flutter run -d web-server
Launching lib\main.dart on Web Server in debug mode...
Building application for the web... 8.8s
lib\main.dart is being served at http://localhost:57598/
Then go to the URL shown.
The same thing happened to me, I disabled the anti virus and it worked
It's mostly nothing to do with Flutter but, it's either because you have logged in your computer in safe mode. In my case the shift key was stuck and I had no idea I was in safe mode.
Or else You need to check your firewall, go to System Preferences > Security and Privacy > Firewall --click the lock below and enter your system password -- and then click firewall option -- In there add your editor to allow internet connection for android studio Or VS Code.
I experienced the something similar, chrome opens but never showed the web app (just white screen). In my case it had to do with the interaction of flutter and riverpod.
If you are using riverpod 1.0.0 and flutter 2.5.3 you need to update flutter to 2.8.0 or 2.8.1 (see this issue: https://github.com/rrousselGit/river_pod/issues/889)

How to get stacktrace from Flutter?

I have a Android/iOS app developed using Flutter through Visual Studio Code. When I run it on Android >=5.0 or any version of iOS it works flawlessly, however it crashes immediately when I run it on Android 4.x (Unfortunately, app has stopped).
I want to fix it, but Flutterdoesn't show me what is happening.
I tried to run through VSCode pushing F5 button and also using command line flutter run, but neither shows me something that I could work with. I tried to run with trace command [Flutter trace run], but it says The --debug-port argument must be specified and I don't know what it means.
I just need a stacktrace or a line error showing me what is the problem. Do I have to configure something on VSCode?
There's a Debug Console available in Visual Studio Code as per checking version 1.51.1. This can be enabled/disabled by navigating through the menu View > Debug Console. Both logs from Android emulator and iOS simulator can be displayed on the Debug Console.
However, if you're looking into checking Flutter debug logs outside of Visual Studio Code, the adb logcat command using the terminal works well for Android as previously mentioned in the comments.
On iOS, one way of checking the logs is through the Console. Press ⌘ + space and type "Console", and press Enter to launch the app. The iOS device should be displayed on the left-side pane of the Console app under Devices. Clicking on the iOS device should display its logs.