LoginSignup
3
2

More than 3 years have passed since last update.

Flutterインストール時のエラー対応(Error: Unable to 'pub upgrade' flutter tool. Retrying in five seconds...)

Posted at

Flutterインストール時に結構ハマったのでメモ。

エラー内容

Pathを通した後に、flutter doctorでエラーが出現。

% which flutter
/Users/mbp/development/flutter/bin/flutter

何回リトライしても、git cloneで入れても、cacheを消しても、エラーが出現する状況。

% flutter doctor
Building flutter tool...
Unhandled exception:
Bad state: Future already completed
#0      _AsyncCompleter.complete (dart:async/future_impl.dart:43:31)
#1      _NativeSocket.startConnect.<anonymous closure>.connectNext.<anonymous closure> (dart:io-patch/socket_patch.dart:682:23)
#2      _NativeSocket.issueWriteEvent.issue (dart:io-patch/socket_patch.dart:1102:14)
#3      _NativeSocket.issueWriteEvent (dart:io-patch/socket_patch.dart:1109:12)
#4      _NativeSocket.multiplex (dart:io-patch/socket_patch.dart:1130:11)
#5      _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:168:12)
Error: Unable to 'pub upgrade' flutter tool. Retrying in five seconds... (9 tries left)

...(中略)...

Unhandled exception:
Bad state: Future already completed
#0      _AsyncCompleter.complete (dart:async/future_impl.dart:43:31)
#1      _NativeSocket.startConnect.<anonymous closure>.connectNext.<anonymous closure> (dart:io-patch/socket_patch.dart:682:23)
#2      _NativeSocket.issueWriteEvent.issue (dart:io-patch/socket_patch.dart:1102:14)
#3      _NativeSocket.issueWriteEvent (dart:io-patch/socket_patch.dart:1109:12)
#4      _NativeSocket.multiplex (dart:io-patch/socket_patch.dart:1130:11)
#5      _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:168:12)
Error: Unable to 'pub upgrade' flutter tool. Retrying in five seconds... (1 tries left)
Command 'pub upgrade' still failed after 10 tries, giving up.

対処

以下対処で解消する可能性あり。
* ファイアーウォールを一時的に無効
* ホワイトリスト編集

私は、アバストのウェブシールドを有効にしていたため、一時的にウェブシールドをオフにすることで、エラーが解消しました。。。

 % flutter doctor -v
[✓] Flutter (Channel stable, 1.22.6, on macOS 11.2.1 20D74 darwin-arm, locale ja-JP)
    • Flutter version 1.22.6 at /Users/mbp/development/flutter
    • Framework revision 9b2d32b605 (4 weeks ago), 2021-01-22 14:36:39 -0800
    • Engine revision 2f0af37152
    • Dart version 2.10.5

[✗] Android toolchain - develop for Android devices
    ✗ Unable to locate Android SDK.
      Install Android Studio from: https://developer.android.com/studio/index.html
      On first launch it will assist you in installing the Android SDK components.
      (or visit https://flutter.dev/docs/get-started/install/macos#android-setup for detailed instructions).
      If the Android SDK has been installed to a custom location, set ANDROID_SDK_ROOT to that location.
      You may also want to add it to your PATH environment variable.


[✗] Xcode - develop for iOS and macOS
    ✗ Xcode installation is incomplete; a full installation is necessary for iOS development.
      Download at: https://developer.apple.com/xcode/download/
      Or install Xcode via the App Store.
      Once installed, run:
        sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer
        sudo xcodebuild -runFirstLaunch
    ✗ CocoaPods not installed.
        CocoaPods is used to retrieve the iOS and macOS platform side's plugin code that responds to your plugin usage on the Dart side.
        Without CocoaPods, plugins will not work on iOS or macOS.
        For more info, see https://flutter.dev/platform-plugins
      To install:
        sudo gem install cocoapods

[!] Android Studio (not installed)
    • Android Studio not found; download from https://developer.android.com/studio/index.html
      (or visit https://flutter.dev/docs/get-started/install/macos#android-setup for detailed instructions).

[!] Connected device
    ! No devices available

! Doctor found issues in 4 categories.
3
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
2