3

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.

Mario359
  • 43
  • 6

2 Answers2

0

After installing your app on the VM, go to Standby apps in the Developer Options and set it to RESTRICTED This will prevent the app from being kept alive this should do the trick.

If that didn't work, enable Don't keep activities and set the Background process limit to No background processes.

Esmaeil Ahmadipour
  • 840
  • 1
  • 11
  • 32
0

By updating Windows subsystem for Android to the latest stable version, I no longer have this issue

WSA Version: 2303.40000.5.0 (Android 13)

Also I added a PATH system variable that might help:

Name: NO_PROXY Value: 127.0.0.1

Mario359
  • 43
  • 6