Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Flutter 2: Error connecting to the service protocol: failed to connect to http://127.0.0.1:1039/ #58588

Tags:

flutter

I'm experiencing an issue with the Flutter template app when launching it on Flutter 2.0.3. I'm getting this output

Launching lib/main.dart on SM J320H in debug mode...
Running Gradle task 'assembleDebug'...
✓ Built build/app/outputs/flutter-apk/app-debug.apk.
Installing build/app/outputs/flutter-apk/app.apk...
Error connecting to the service protocol: failed to connect to http://127.0.0.1:62719/OJaWBfEtnmY=/

I'm launching this app on a real Android device. When launching with Flutter 1.22.5 - everything works fine.

Flutter doctor output:

Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 2.0.3, on Mac OS X 10.15.7 19H2 darwin-x64, locale
    en-UA)
[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
[✓] Xcode - develop for iOS and macOS
[✓] Chrome - develop for the web
[✓] Android Studio (version 4.1)
[✓] IntelliJ IDEA Ultimate Edition (version 2020.1.1)
[✓] VS Code (version 1.54.3)
[✓] Connected device (2 available)

• No issues found!
like image 936
Leo Avatar asked Apr 02 '21 08:04

Leo


2 Answers

I just got the same problem. It's because of your dart and flutter versions I guess.

Just run flutter upgrade and flutter clean to solve the problem.

Similar problem solutions here: https://github.com/flutter/flutter/issues/47204

This helped me. Here is the log:

PS D:\Documents\Work\bus_stop_routes> flutter clean
Deleting build...                                                  629ms
Deleting .dart_tool...                                             567ms
Deleting .packages...                                                0ms
Deleting Generated.xcconfig...                                       0ms
Deleting flutter_export_environment.sh...                            0ms
Deleting .flutter-plugins-dependencies...                            0ms
Deleting .flutter-plugins...                                         0ms
PS D:\Documents\Work\bus_stop_routes> flutter pub get
Running "flutter pub get" in bus_stop_routes...                     3.4s
PS D:\Documents\Work\bus_stop_routes> flutter run
Launching lib\main.dart on SM N910H in debug mode...
Note: C:\flutter\.pub-cache\hosted\pub.dartlang.org\google_maps_flutter-2.0.1\android\src\main\java\io\flutter\plugins\googlemaps\Convert.java uses or overrides a deprecated API.
Running Gradle task 'assembleDebug'...
Running Gradle task 'assembleDebug'... Done                        46.3s
√ Built build\app\outputs\flutter-apk\app-debug.apk.
Installing build\app\outputs\flutter-apk\app.apk...                29.0s
Activating Dart DevTools...                                         3.1s
Error connecting to the service protocol: failed to connect to http://127.0.0.1:58851/a7SAG7gM8aI=/
PS D:\Documents\Work\bus_stop_routes> dart upgrade
Could not find a command named "upgrade".

Usage: dart [<vm-flags>] <command|dart-file> [<arguments>]

Global options:
-h, --help                 Print this usage information.
-v, --verbose              Show additional command output.
    --version              Print the Dart SDK version.
    --enable-analytics     Enable anonymous analytics.
    --disable-analytics    Disable anonymous analytics.

Available commands:
  analyze   Analyze the projects Dart code.
  compile   Compile Dart to various formats.
  create    Create a new project.
  fix       Apply automated fixes to Dart source code.
  format    Idiomatically format Dart source code.
  migrate   Perform a null safety migration on a project or package.
  pub       Work with packages.
  run       Run a Dart program.
  test      Run tests in this package.

Run "dart help <command>" for more information about a command.
See https://dart.dev/tools/dart-tool for detailed documentation.
PS D:\Documents\Work\bus_stop_routes> flutter upgrade
Upgrading Flutter to 2.0.4 from 2.0.3 in C:\flutter...
Checking Dart SDK version... 
Downloading Dart SDK from Flutter engine 2dce47073a378673f6ca095e91b8065544c3a881...       
Building flutter tool... 
Running pub upgrade... 

Upgrading engine...
Downloading android-arm-profile/windows-x64 tools...               20.1s
Downloading android-arm-release/windows-x64 tools...                8.7s
Downloading android-arm64-profile/windows-x64 tools...              9.7s
Downloading android-arm64-release/windows-x64 tools...              8.2s
Downloading android-x64-profile/windows-x64 tools...                9.3s
Downloading android-x64-release/windows-x64 tools...                7.9s
Downloading android-x86 tools...                                   98.3s
Downloading android-x64 tools...                                   64.8s
Downloading android-arm tools...                                   15.6s
Downloading android-arm-release tools...                           12.4s
Downloading android-arm64 tools...                                 36.2s
Downloading android-arm64-profile tools...                         18.1s
Downloading android-arm64-release tools...                         14.6s
Downloading android-x64-profile tools...                           19.0s
Downloading android-x64-release tools...                           15.0s
Downloading android-x86-jit-release tools...                       21.6s
Downloading Web SDK...                                             42.0s

Flutter 2.0.4 • channel stable • https://github.com/flutter/flutter.git
Framework • revision b1395592de (7 days ago) • 2021-04-01 14:25:01 -0700
Engine • revision 2dce47073a
Tools • Dart 2.12.2

Running flutter doctor...
Doctor summary (to see all details, run flutter doctor -v):
[√] Flutter (Channel stable, 2.0.4, on Microsoft Windows [Version 10.0.19042.867], locale en-US)
[√] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
[√] Chrome - develop for the web
[√] Android Studio (version 4.1.0)
[√] VS Code (version 1.55.0)
[√] Connected device (3 available)

• No issues found!
PS D:\Documents\Work\bus_stop_routes> flutter run
Running "flutter pub get" in bus_stop_routes...                  1,114ms
Launching lib\main.dart on SM N910H in debug mode...
Running Gradle task 'assembleDebug'...                                  
Running Gradle task 'assembleDebug'... Done                       107.2s
√ Built build\app\outputs\flutter-apk\app-debug.apk.
Installing build\app\outputs\flutter-apk\app.apk...                29.2s
Syncing files to device SM N910H...                                141ms

Flutter run key commands.
r Hot reload.
R Hot restart.
h Repeat this help message.
d Detach (terminate "flutter run" but leave application running).
c Clear the screen
q Quit (terminate the application on the device).
An Observatory debugger and profiler on SM N910H is available at:
http://127.0.0.1:60828/axOQuzsu83M=/

If not solved, it's about the extension that you using.

  • Please reopen your editor after this. But sometimes that not working when you use extensions.

  • I also checked the virus defender. And allowed the permission.

enter image description here

like image 189
Mr White Avatar answered Nov 15 '22 04:11

Mr White


I experience this issue when I add certain plugins or when I open the project in both Visual Studio Code and Android Studio.

If all other attempts to resolve this issue fails, restart your test device. This has worked for me.

like image 30
Edwin Nyawoli Avatar answered Nov 15 '22 05:11

Edwin Nyawoli