【问题标题】:Trouble with running and hot reloading flutter in Android studio(Bad state: Future already completed)在 Android Studio 中运行和热重载颤振的问题(坏状态:未来已经完成)
【发布时间】:2019-06-24 19:40:11
【问题描述】:

这个issue已经提交到Flutter github issues:https://github.com/flutter/flutter/issues/27450

我在 Android Studio 中运行和热重载 Flutter 应用时遇到了一些问题。

当我在 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)

我根本无法让热重载工作

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)

我正在开发稳定的频道。这是我的颤振医生的输出:

[✓] 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)

我目前在中国工作,我已经实施了这里提到的更改:https://flutter.io/community/china。这是我的 .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

我正在使用 Mac。

【问题讨论】:

标签: flutter


【解决方案1】:

这似乎是与网络相关的问题。

我对此的解决方法: 我已经从我的 .bash_profile 文件中删除了 PUB_HOSTED_URL 和 FLUTTER_STORAGE_BASE_URL 并打开了我的 VPN。

看起来您需要一个活跃且稳定的互联网连接来构建和热重载正在开发的 Flutter 应用程序。

相关链接:

【讨论】:

    【解决方案2】:

    我建议您按照中使用的步骤再次安装flutter 这个流行的颤振课程视频。我希望它值得一看 为您服务,您的错误将被删除Flutter Installation Guide 因为你来自中国,所以你必须添加这些步骤,如中所述 链接Using Flutter In China

    【讨论】:

    • 感谢您的回复。我已按照 Flutter 开发站点的安装步骤进行操作。我也实现了“在中国使用flutter”链接中的步骤。它似乎没有帮助。
    【解决方案3】:

    这看起来可能是个奇怪的建议;但是,您在完成此操作时是否尝试过使用 vpn?我曾经遇到过这个问题,然后使用 vpn 连接帮助了我。我想,你可以试试看。

    【讨论】:

    • 是的,我认为我不能从我的 bask 个人资料中注释掉 PUB_HOSTED_URL 和 FLUTTER_STORAGE_BASE_URL 并使用 VPN。
    【解决方案4】:

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

    NO_PROXY=127.0.0.1,localhost
    

    【讨论】:

    • 我没有使用代理。
    猜你喜欢
    • 2020-04-18
    • 2021-05-05
    • 2018-12-26
    • 1970-01-01
    • 2020-04-17
    • 1970-01-01
    • 2021-03-30
    • 2018-09-26
    • 2019-11-29
    相关资源
    最近更新 更多