Since some days, I am unable to debug a Flutter app with Windows subsystem for Android properly. Sometimes it works fine, but after a few minutes the debugger disconnect.
To connect on WSA I use:
adb connect 127.0.0.1:58526
Those are the logs I get when I run and debug my app:
Launching lib\main.dart on Subsystem for Android TM in debug mode...
Running Gradle task 'assembleDebug'... 7,5s
√ Built build\app\outputs\flutter-apk\app-debug.apk.
I/flutter ( 1706): Could not start Dart VM service HTTP server:
I/flutter ( 1706): SocketException: Failed to create server socket (OS Error: Function not implemented, errno = 38), address = 127.0.0.1, port = 0
I/flutter ( 1706): #0 _NativeSocket.bind (dart:io-patch/socket_patch.dart:996:7)
I/flutter ( 1706): <asynchronous suspension>
I/flutter ( 1706): #1 Server.startup.startServer (dart:vmservice_io/vmservice_server.dart:430:19)
I/flutter ( 1706): <asynchronous suspension>
I/flutter ( 1706): #2 Server.startup (dart:vmservice_io/vmservice_server.dart:449:11)
I/flutter ( 1706): <asynchronous suspension>
Once this error message appear, my app is launched but get stuck at splash screen (with Flutter icon)
The only solution I have is to restart the Subsystem for Android, then my app works for some minutes and the problem is back.
With React Native, a similar problem appear at the same time I had this problem with Flutter, the solution was to execute this command:
adb reverse tcp:8081 tcp:8081
It may be a change in the newest version of Subsystem for Android.