首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Flutter 2:连接到服务协议时出错:无法连接到http://127.0.0.1:1039/ #58588

Flutter 2:连接到服务协议时出错:无法连接到http://127.0.0.1:1039/ #58588
EN

Stack Overflow用户
提问于 2021-04-02 16:17:06
回答 3查看 6.1K关注 0票数 5

在Flutter 2.0.3上启动Flutter模板应用程序时,我遇到了一个问题。我得到了这个输出

代码语言:javascript
复制
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=/

我要在一个真正的Android设备上启动这个应用程序。当使用Flutter 1.22.5启动时-一切正常。

颤动医生输出:

代码语言:javascript
复制
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!
EN

回答 3

Stack Overflow用户

发布于 2021-04-09 11:23:55

我也遇到了同样的问题。我猜是因为你的飞镖和扑翼版本。

只需运行flutter upgradeflutter clean即可解决问题。

类似的问题解决方案:https://github.com/flutter/flutter/issues/47204

这对我很有帮助。日志如下:

代码语言:javascript
复制
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=/

如果没有解决,那就是关于你使用的扩展。

  • 请在此之后重新打开编辑器。但有时当您使用扩展时,这并不起作用。

  • 我也检查了病毒防御者。并允许该权限。

票数 4
EN

Stack Overflow用户

发布于 2021-04-22 17:56:53

当我添加某些插件或者在Visual Studio Code和Android Studio中打开项目时,我遇到了这个问题。

如果解决此问题的所有其他尝试都失败,请重新启动测试设备。这对我很有效。

票数 1
EN

Stack Overflow用户

发布于 2021-04-03 06:45:53

要解决这个问题,可以使用带有API28的android模拟器(Android 9)……

试试看,告诉我你的问题有没有解决。

票数 -2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/66916397

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档