Reputation: 775
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.
Upvotes: 61
Views: 92552
Reputation: 87
i got this error during run my flutter app no physical device: issue: Error connecting to the service protocol: failed to connect to http://127.0.0.1:54869/2CMry_Tdav4=/
Solution for this(it works for me): Just restart your physical device and turn off and again turn on USB debugging option from developer option on your device..!
Upvotes: 0
Reputation: 11
I'm writing for the IntelliJ IDEA solution, probably the same in Android Studio. Add a new rule to the 'Inbound Rules' and 'Outbound Rules' sections of the firewall, and grant access to the program located at IntellijIDEAPath\jbr\bin\jcef_helper.exe. Example path: C:\Program Files\JetBrains\IntelliJ IDEA Community Version 2022.3.3\jbr\bin\jcef_helper.exe
Upvotes: 0
Reputation: 5616
to my case after upgrading flutter_facebook_auth
^3.5.0
to ^5.0.8
version i had to add FacebookClientToken
iOS
Info.plist
<key>FacebookClientToken</key>
<string>YOUR-TOKEN-HERE</string>
https://developers.facebook.com/docs/ios/getting-started#configure-your-project
Android
/app/manifests/AndroidManifest.xml
<meta-data android:name="com.facebook.sdk.ClientToken" android:value="YOUT TOKEN HERE"/>
https://developers.facebook.com/docs/android/getting-started#configure-your-project
Upvotes: 1
Reputation: 11
In my case :
1- lock the emulator from the the normal screen locking button.
2- unlock the emulator.
3- Press the run button in Android studio.
Upvotes: 0
Reputation: 2086
I had the same issue when running flutter app in vscode. Here's my vscode launch configuration.
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Flutter",
"request": "launch",
"type": "dart",
"flutterMode": "debug",
"args": [
"--verbose"
]
}
]
}
And because i use proxy, i have some proxy settigns in environment.
export https_proxy=http://172.23.32.1:7890
export http_proxy=http://172.23.32.1:7890
export no_proxy=localhost,127.0.0.1,127.0.0.0,127.0.1.1,127.0.1.1,local.home,::1
At the beginning i didn't know why i had this problem "Error connecting to the service protocol: HttpException: Connection closed before full header was received, uri = http://127.0.0.1:xxxx/xxxx=/ws"
I tried netstat -altp | grep xxxx
I can see port is listened.
My Solution
I restart vscode then it works.
Upvotes: -1
Reputation: 21
If not all above them works for you.
It just worked for me
Upvotes: 2
Reputation: 21
For me, I use an external device to run the output and it fails to connect the debugging url. The reason what I think is the connection between my device and PC was lost during synchronizing the data So for that, I just revoke the debugging option from the developer options in the settings. For an emulator that is created by android studio, I sue to clean the data/ wipe data/ or go to settings inside the emulator and go to storage then clear the cache data (if an app is preinstalled manually uninstall the flutter app then remove the cache). Also, run fluter clean and flutter pub get in the terminal/cmd then flutter run to target the emulator or personal device.
Upvotes: 0
Reputation: 11
check if you have enough storage in your phone.
I had the same problem and that was the reason.
Upvotes: 1
Reputation: 14918
Open AVD from Android Studio and clear data of emulator and re-run again. it worked for me.
Upvotes: 0
Reputation: 1754
If you are using Flutter 2.10
or higher it may be that you tried to emulate a Windows desktop
app but you don't have Visual Studio - develop for Windows (Visual Studio Community 2022 17.1.0)
installed.
Apparently, it won't let you emulate anything until you install VS.
Run flutter doctor
to find out.
Upvotes: 1
Reputation: 188
I solved this problem by:
By doing this, you will restart the VM Service.
Upvotes: 7
Reputation: 53
I had faced the same issue but the only thing which solved my problem is to uninstall the app on my physical phone and I again try to run. and truly its work.
Upvotes: 1
Reputation: 71
I had a simliar problem with ios with the error message Error connecting to the service protocol: failed to connect to http://127.0.0.1:......
. I solved it by removing the app from the simulator and ran a clean in xcode, then it could build successfully from vs code!
Upvotes: 1
Reputation: 344
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
Upvotes: 14
Reputation: 153
This happened to me too, the problem was I was using a vpn in my PC, I turned the vpn off, and everything just worked fine
Upvotes: 0
Reputation: 54
Try
flutter doctor -v
I had faced same issue. So I run flutter doctor -v command.
Then I found the error
✗ Android licenses not accepted. To resolve this, run: flutter doctor --android-licenses.
flutter doctor --android-licenses this command resolved my issue.
Upvotes: 2
Reputation: 1
I was having the same error message. In my case, the problem was just a configuration that I changed in Runner.xcodeproj.
Open runner.xcodeproj in Xcode, go to the General tab -> App Icons and Lauch Images -> "Launch Screen File". I had changed it to Main and that cause the error, changing back to "LaunchScreen" option solved the problem for me.
Upvotes: 0
Reputation: 182
I have resolved this problem after add some code in android folder.
1.Add below code in AndroidManifest.xml
<meta-data android:name="com.facebook.sdk.ApplicationId"
android:value="@string/facebook_app_id"/>
<activity android:name="com.facebook.FacebookActivity"
android:configChanges=
"keyboard|keyboardHidden|screenLayout|screenSize|orientation"
android:label="@string/app_name" />
<activity
android:name="com.facebook.CustomTabActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="@string/fb_login_protocol_scheme" />
</intent-filter>
</activity>
2.Add your Facebook app id in strings.xml
<string name="facebook_app_id">380000000000000</string>
<string name="fb_login_protocol_scheme">fb380000000000000</string>
3.Add dependencies in pubspec.yaml
flutter_facebook_login: ^1.1.1
Pub get and run.
Upvotes: 0
Reputation: 145
For me, it was caused by phone screen saver. Emulator screen was locked. After I pressed on power icon, the screen opened. then I run it again and everything is working.
Upvotes: 0
Reputation: 637
When I deleted the emulator in AVD Manager and rebuilt it, it worked.
Upvotes: 0
Reputation: 684
In virtual device manager, try one of these options.
Wipe Data
Cold Boot Now
Upvotes: 4
Reputation: 1209
Open the project in android studio => Start your Emulator - OR - Connect your android device with Debug mode "on" => Run the Project on android studio => Run your project from VS code or from command line using flutter run
Upvotes: 0
Reputation: 1439
For me it was caused by flutter_facebook_login plugin causing issue i removed it and i could afford to remove facebook login option but in your case you can try different version of flutter_facebook_login or you can use different plugin for loggin in using facebook.
Upvotes: 0
Reputation: 1740
I have the same problem and I go to xcode -> window -> device & simulator, under Installed Apps I remove some apps and it works.
Upvotes: 0
Reputation: 1676
For my case, I met the error when I used 3rd parties such as facebook_login, twitter_login incorrectly.
To check:
To fix:
Hope this help.
Upvotes: 5
Reputation: 1576
It seems it can be different things. In my case, I removed a package I was using, barcode_scan.
Upvotes: 0