9
8

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

Flutterのビルドエラーを解決できるかもしれない方法

Last updated at Posted at 2021-04-09

事象

VSCodeなどのデバッグビルドが突然、Exited (sigterm)で終了するようになり、原因が全くわからない状態
この事象にハマると平気で2〜3時間ぐらい毎回費やしてしまうので備忘。

Launching lib/main.dart on iPhone 11 in debug mode...
lib/main.dart:1
Xcode build done.                                           35.7s
Exited (sigterm)

詳細をみてみると、こんなエラーも起きてたりする。

flutter run --verbose
ios/Flutter/App.framework" failed: No such file or directory (2) done flutter

結論

flutter pub get で './pub-cache' にインストールさたモジュールをデバッグの際になんらかのタイミングで触ってしまい、
構文エラーが起きていることが多い。

解決に至るまで

flutter clean (=> ダメ)

flutter cleanを行い、再度、flutter pub getを行う

flutter clean
flutter pub get

flutterの再インストール (=> ダメ)

fvmを使っての再インストール

fvm remove 1.22.6(YOUR FLUTTER VERSION)
fvm install 1.22.6

flutetr run --verbose で、以下のエラーログを発見

⣽[   +9 ms] executing: [/Users/hogehoge/works/project/app/ios/Runner.xcodeproj/] /usr/bin/xcodebuild -project /Users/hogehoge/works/project/app/ios/Runner.xcodeproj -scheme Runner -showBuildSettings
[        ] executing: [/Users/hogehoge/works/project/app/ios/Runner.xcodeproj/] /usr/bin/xcodebuild -project /Users/hogehoge/works/project/app/ios/Runner.xcodeproj -scheme Runner -showBuildSettings
⣽[ +821 ms] ../../../.pub-cache/hosted/pub.dartlang.org/state_notifier-0.5.0/lib/state_notifier.dart:116:19: Error: Expected an identifier, but got '\'.
[        ]       return true;\
[        ]                   ^
[   +5 ms] ../../../.pub-cache/hosted/pub.dartlang.org/state_notifier-0.5.0/lib/state_notifier.dart:117:5: Error: Expected ';' after this.
[        ]     }());
[        ]     ^

どうやら、
../../../.pub-cache/hosted/pub.dartlang.org/state_notifier-0.5.0/lib/state_notifier.dart
の構文でエラーが起きているっぽい。

解決策

構文エラーが起きている ./pub-cacheの中身のdartファイルを直接修正しても良いが、以下コマンドで解決する。

flutter pub cache repair

参考

9
8
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
9
8

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?