I am having an Issue with Flutter in Android studio, where whenever I run my flutter app, it will print this error; "Error connecting to the service protocol: HttpException: Connection closed before full header was received, uri = http://127.0.0.1:53305/9So9Wn564F4=/ws" , and it will "disconnect" from the app in the emulator. The app will still run, but I can't use functions like Hot Reload.
I am on a Windows machine, and Flutter Doctor does not indicate any errors. I have tried to read up on similar issues on github posts, but I have been unable to resolve the problem.
Do any of you guys have any ideas on how to solve this issue?
The problem does not occur when running on an actual device, only in the emulator.
If you return to a previous version of android, (Android Pie), you will no longer have this problem, it is related only to the latest versions of android (Q, 29), in others you will no longer have the problem.
A quick restart of the phone worked for me
Hey I went into the same problem too. I cannot use a Emulator inside windows because my pc is a very low end pc. So, I had to use my phone instead. It is a Samsung Galaxy J2 Pro (SM-J210F) with Android 6.0.1 (Android Marshmallow). I used that phone to develop flutter apps regularly, but suddenly, I went to this problem.
Here's what happened when I tried to run "Flutter Attach" in VS-Code(v1.52.0).
flutter attach --machine -d 420054e7960eb400
StateError: Bad state: Existing VM service clients prevent DDS from taking control.
#0 DartDevelopmentService.startDartDevelopmentService (package:flutter_tools/src/base/dds.dart:83:11)
<asynchronous suspension>
#1 FlutterDevice.connect.<anonymous closure> (package:flutter_tools/src/resident_runner.dart:249:11)
<asynchronous suspension>
So, I ran these commands to fix the issue.
-flutter clean -v
-flutter channel stable ** (Optional if these didn't fix the issue)
-flutter upgrade -v
-flutter pub cache repair -v (Disclaimer: It will download each and every version of all the packages. Be sure to have really fast internet or give at least an hour to this.)
If you are using a Proxy or VPN to connect to the internet,
Make sure that application isn't resolving localhost via that.(DNS)
After that, kill adb and dart process on Windows.
(I don't know exactly how to kill these in Mac/Linux. Sorry About That)
Run these commands in the Command Prompt.
taskkill /f /im dart*
taskkill /f /im adb* (You can run "adb kill-server" too)
Navigate to %HOMEDRIVE%:\Users%USERNAME%.android"
In my case, It is ( C:\Users\Isira Adithya.android )
Then delete adbkey.
Disconnect the device from the computer.
Go to Settings -> Developer Options,
Turn off USB Debugging and Turn it on again.
Revoke USB Debugging authorizations.
Restart the device.
I think these steps should fix your problem.
Also I am still 16 years old and I am not a very experienced developer.
If these didn't fix, use this to get more info. Github Issue
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With