Qiita Teams that are logged in
You are not logged in to any team

Log in to Qiita Team
Community
OrganizationAdvent CalendarQiitadon (β)
Service
Qiita JobsQiita ZineQiita Blog
Help us understand the problem. What is going on with this article?

[Dart/Flutter] エラー対応記事 (継続追記用)

More than 1 year has passed since last update.

概要

Flutterのエラー対応に関しての記事をどんどん追記記載していく

経緯

Flutterを運用していく時に、数々のエラーが発生します。
その度にググって対応してきたのですが、少しでもまとまっていた便利かなと思いまとめました。
基本的なエラーもあれば、普通は起きないものもあるとは思いますが、とりあえずはどんどん記載して、ある程度溜まってきた段階で依存する問題のカテゴライズもできたらと思います。

エラー一覧

Flutter run した時に起きたエラー

1. FileSystemException: FileSystemException: Getting current working directory failed, path = '' (OS Error: Too many open files, errno = 24)

$ flutter run
Launching lib/main.dart on iPhone Xs in debug mode...

Oops; flutter has exited unexpectedly.
Sending crash report to Google.
Crash report sent (report ID: 2f1faa90781c3c03)
flutter_01.log
Flutter crash report; please file at https://github.com/flutter/flutter/issues.

## command

flutter run

## exception

FileSystemException: FileSystemException: Getting current working directory failed, path = '' (OS Error: Too many open files, errno = 24)

・・・

解決方法

$ ulimit -S -n 2048 で解決

$ ulimit -S -n 2048
$ flutter run 
Launching lib/main.dart on iPhone Xs in debug mode...
Running Xcode build...                                                  

 ├─Assembling Flutter resources...                           2.6s
 └─Compiling, linking and signing...                         6.6s
Xcode build done.                                           11.5s

・・・

参考

https://github.com/trentpiercy/trace/issues/1

2. Framework File Duplicate

発生タイミング

$ flutter build ios --release
を実行してbuild fileを生成した後に
$ flutter run
を実行すると吐く

    === BUILD TARGET Runner OF PROJECT Runner WITH CONFIGURATION Debug ===
    2019-11-10 17:17:12.208 defaults[55665:38131764] 
    The domain/default pair of
    (/Users/SampleApp/build/ios/Debug-iphonesimulator/Runner.app/F
    rameworks/App.framework/flutter_assets/ios/Flutter/App%202.framework/Info.plist,
    CFBundleExecutable) does not exist
    fatal error: lipo: can't map input file:
    /Users/SampleApp/build/ios/Debug-iphonesimulator/Runner.app/Fr
    ameworks/App.framework/flutter_assets/ios/Flutter/App%202.framework/ (Invalid argument)
    fatal error: lipo: can't map input file:
    /Users/SampleApp/build/ios/Debug-iphonesimulator/Runner.app/Fr
    ameworks/App.framework/flutter_assets/ios/Flutter/App%202.framework/ (Invalid argument)
    Failed to extract x86_64 for
    /Users/SampleApp/build/ios/Debug-iphonesimulator/Runner.app/Fr
    ameworks/App.framework/flutter_assets/ios/Flutter/App%202.framework/. Running lipo -info:
    fatal error: lipo: can't map input file:
    /Users/SampleApp/build/ios/Debug-iphonesimulator/Runner.app/Fr
    ameworks/App.framework/flutter_assets/ios/Flutter/App%202.framework/ (Invalid argument)

解決策

ios/Flutter 配下の App 2.framework および Flutter 2.framework などと重複して生成されているファイルを削除する。

※ 時々、ios/Pods配下のフォルダー内でも重複が発生したり、ios/Podfile.lockが複製されたりするので、この際は、
$ rm -rf ios/Pods
$ rm -rf ios/Podfile.lock
実行するなどして削除後、
$ cd ios でios配下に移動し、
$ pod install
を実行すると正常化される現象も確認されています。

3. The application's Info.plist does not contain CFBundleVersion.

発生タイミング

$ flutter run した際に発生
以下のエラーメッセージが表示される

Sending crash report to Google.
Crash report sent (report ID: 7653dd7440c7c434)
Oops; flutter has exited unexpectedly.
Crash report written to /Users/ryoichikataoka/Desktop/Shakey-flutter/shakey/flutter_03.log;
please let us know at https://github.com/flutter/flutter/issues.

Error logが作成されているようなのでこちらを見てみる。

flutter.logを見るとこんな感じで記載されている

flutter_01.log
ProcessException: ProcessException: Process "/usr/bin/xcrun" exited abnormally:
An error was encountered processing the command (domain=NSPOSIXErrorDomain, code=22):
Failed to install the requested application
The application's Info.plist does not contain CFBundleVersion.
Ensure your bundle contains a CFBundleVersion.

解決策-1

  1. Simulator の menu barに行く
  2. Hardwareを選択
  3. Erase All Content and SettingでHardwareの初期化を実行

解決策-2

ios/Runner/info.plist に追記する。

info.plist
・・・
<dict>
    <key>CFBundleVersion</key>
    <string>$(FLUTTER_BUILD_NUMBER)</string>
・・・
</dict>

参考

https://stackoverflow.com/questions/43111501/the-bundles-info-plist-does-not-contain-a-cfbundleversion-key-or-its-value-is-n

Kata_Oka
トイレが好きすぎてフランスに飛び、学問に限界を感じ帰国。 帰国後トイレ研究を広めたくてIT業界に入りもうそろ2年。 日々、トイレに入っては自問自答。 ちなみに家のトイレは便器はINAX、温水洗浄便座はTOTOのハイブリッド。
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away