Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

flutter

This issue has been submitted to the Flutter github issues: https://github.com/flutter/flutter/issues/27450

I am having some trouble with running and hot reloading flutter apps in Android studio.

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.

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. Here are the relevant parts of my .bash_profile file

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.

like image 431
DrkStr Avatar asked Jan 31 '19 10:01

DrkStr


1 Answers

This might look like a weird suggestion; however, did you try using vpn while completing this action? I once faced this problem, then using a vpn connection helped me. I guess, you may give it a try.

like image 122
onosecond Avatar answered Nov 15 '22 06:11

onosecond