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

nwwlzxa7  于 2023-10-22  发布在  Flutter
关注(0)|答案(5)|浏览(216)

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

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=/

我要在一个真实的安卓设备上启动这个应用程序。当使用Flutter 1.22.5启动时-一切正常。
Flutter刮刀输出:

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!
u3r8eeie

u3r8eeie1#

我也有同样的问题。我想是因为你的 dart 和扑翼版本。
只需运行flutter upgradeflutter clean即可解决问题。
类似的问题解决方案在这里:https://github.com/flutter/flutter/issues/47204
这帮助了我。下面是日志:

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=/

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

  • 请在此之后重新打开编辑器。但有时候,当你使用扩展时,这并不起作用。
  • 我也查了病毒防御者。并获得了许可。

w51jfk4q

w51jfk4q2#

当我添加某些插件或在Visual Studio Code和Android Studio中打开项目时,我会遇到此问题。
如果解决此问题的所有其他尝试均失败,请重新启动测试设备。这对我很有效。

p8h8hvxi

p8h8hvxi3#

重新启动您的设备将完美地工作

isr3a4wc

isr3a4wc4#

我不确定物理设备是否有等效的,但以下是我如何为Android的Microsoft Windows子系统修复它:我让它通过了防火墙。在Windows 11上,以下是如何:
开始->允许应用程序通过Windows防火墙-> Windows Subsystem for Android(TM)
勾选未勾选的框,然后你就可以开始了。我希望能帮上忙。

jtoj6r0c

jtoj6r0c5#

要解决它,使用Android模拟器与API 28(Android 9).
试试看,告诉我是否解决了你的问题...

相关问题