简体   繁体   English

在Android工作室中运行和热重载颤动的问题(糟糕的状态:未来已经完成)

[英]Trouble with running and hot reloading flutter in Android studio(Bad state: Future already completed)

This issue has been submitted to the Flutter github issues: https://github.com/flutter/flutter/issues/27450 此问题已提交给Flutter github问题: https//github.com/flutter/flutter/issues/27450

I am having some trouble with running and hot reloading flutter apps in Android studio. 我在Android Studio中运行和热重新加载flutter应用程序时遇到了一些麻烦。

When I run an app in Android studio, I get the following message every now and again(2 out of 3 runs) and the build fails. 当我在Android studio中运行应用程序时,我不时会收到以下消息(3次运行中有2次),并且构建失败。

Launching lib/main.dart on iPhone XR in debug mode...
Unhandled exception:
Bad state: Future already completed
#0      _AsyncCompleter.complete (dart:async/future_impl.dart:39:31)
#1      _NativeSocket.startConnect.<anonymous closure>.connectNext.<anonymous closure> (dart:io/runtime/binsocket_patch.dart:490:23)
#2      _NativeSocket.issueWriteEvent.issue (dart:io/runtime/binsocket_patch.dart:844:14)
#3      _NativeSocket.issueWriteEvent (dart:io/runtime/binsocket_patch.dart:851:12)
#4      _NativeSocket.multiplex (dart:io/runtime/binsocket_patch.dart:872:11)
#5      _RawReceivePortImpl._handleMessage (dart:isolate/runtime/libisolate_patch.dart:171:12)

I have not been able to get hot reload to work at all 我根本无法进行热重装工作

Performing hot reload...
Syncing files to device iPhone XR...
Unhandled exception:
Bad state: Future already completed
#0      _AsyncCompleter.complete (dart:async/future_impl.dart:39:31)
#1      _NativeSocket.startConnect.<anonymous closure>.connectNext.<anonymous closure> (dart:io/runtime/binsocket_patch.dart:490:23)
#2      _NativeSocket.issueWriteEvent.issue (dart:io/runtime/binsocket_patch.dart:844:14)
#3      _NativeSocket.issueWriteEvent (dart:io/runtime/binsocket_patch.dart:851:12)
#4      _NativeSocket.multiplex (dart:io/runtime/binsocket_patch.dart:872:11)
#5      _RawReceivePortImpl._handleMessage (dart:isolate/runtime/libisolate_patch.dart:171:12)

I am working on the stable channel. 我正在稳定的渠道上工作。 Here is my output of flutter doctor: 这是我的颤振医生的输出:

[✓] Flutter (Channel stable, v1.0.0, on Mac OS X 10.14.1 18B75, locale en-AU)
• Flutter version 1.0.0 at /Users/rakshak/flutter
• Framework revision 5391447fae (9 weeks ago), 2018-11-29 19:41:26 -0800
• Engine revision 7375a0f414
• Dart version 2.1.0 (build 2.1.0-dev.9.4 f9ebf21297)

⣽Unhandled exception:
Bad state: Future already completed
#0      _AsyncCompleter.complete (dart:async/future_impl.dart:39:31)
#1      _NativeSocket.startConnect.<anonymous closure>.connectNext.<anonymous closure> (dart:io/runtime/binsocket_patch.dart:490:23)
#2      _NativeSocket.issueWriteEvent.issue (dart:io/runtime/binsocket_patch.dart:844:14)
#3      _NativeSocket.issueWriteEvent (dart:io/runtime/binsocket_patch.dart:851:12)
#4      _NativeSocket.multiplex (dart:io/runtime/binsocket_patch.dart:872:11)
#5      _RawReceivePortImpl._handleMessage (dart:isolate/runtime/libisolate_patch.dart:171:12)

I am working from China at the moment, I have implemented the changes mentioned here: https://flutter.io/community/china . 我目前在中国工作,我已经实现了这里提到的更改: https//flutter.io/community/china Here are the relevant parts of my .bash_profile file 以下是我的.bash_profile文件的相关部分

export PUB_HOSTED_URL=https://pub.flutter-io.cn
export FLUTTER_STORAGE_BASE_URL=https://storage.flutter-io.cn
export PATH=$PATH:/Users/rakshak/flutter/bin

I am working on a Mac. 我正在使用Mac。

This might look like a weird suggestion; 这可能看起来像一个奇怪的建议; however, did you try using vpn while completing this action? 但是,您是否尝试在完成此操作时使用vpn? I once faced this problem, then using a vpn connection helped me. 我曾经遇到过这个问题,然后使用vpn连接帮助了我。 I guess, you may give it a try. 我想,你可以尝试一下。

I recommend you to install again flutter following the steps used in this popular flutter course video. 我建议您按照这个流行的颤动课程视频中使用的步骤再次安装颤振。 I hope it will be worth watching for you and your error will be removed Flutter Installation Guide As you are from China, so you have to add these steps as mentioned in the link Using Flutter In China 我希望值得关注你,你的错误将被删除Flutter安装指南因为你来自中国,所以你必须添加这些步骤,如链接中使用Flutter在中国

如果您使用代理,请设置环境变量

NO_PROXY=127.0.0.1,localhost

This seems to have been a network related issue. 这似乎是一个与网络相关的问题。

My fix for this: I have removed PUB_HOSTED_URL and FLUTTER_STORAGE_BASE_URL from my .bash_profile file and turned on my VPN. 我对此的修复:我已从.bash_profile文件中删除了PUB_HOSTED_URL和FLUTTER_STORAGE_BASE_URL并打开了我的VPN。

It looks like you need an active and stable internet connection to build and hot reload a flutter app in development. 看起来您需要一个活跃且稳定的互联网连接来构建和热重新加载开发中的颤动应用程序。

Related links: 相关链接:

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 坏 state:未来已经在 Flutter 完成 - Bad state: Future already completed in Flutter 未处理的异常:状态不佳:未来已在颤动中完成 - Unhandled Exception: Bad state: Future already completed in flutter Flutter 安装错误,“错误状态:未来已经完成” - Flutter install error, "Bad state: Future already completed" Flutter 多个 WebView 小部件错误“错误 state:未来已完成” - Flutter multiple WebView widget error "Bad state: Future already completed" Flutter:Google Maps StateError(错误状态:未来已经完成) - Flutter: Google Maps StateError (Bad state: Future already completed) Flutter Dio 拦截器错误:错误 state:未来已完成 - Flutter Dio interceptor Error: Bad state: Future already completed google_maps_flutter 插件不适用于 Android 显示错误错误 state:未来已完成 - google_maps_flutter plugin not working on Android shows Error Bad state: Future already completed 未处理的异常:错误状态:未来已经完成 - Unhandled exception: Bad state: Future already completed 例外:坏 state:未来已经完成 - Exception: bad state: Future already completed Mac OS Big sur Flutter 安装错误,“状态不佳:未来已经完成” - Mac OS Big sur Flutter install error, “Bad state: Future already completed”
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM