【Flutter】flutter_launcher_iconsを使ってアプリアイコンを設定したら「Invalid App Store Icon.」エラーの時の対応
概要
Flutterでアプリアイコンを作成する場合、「flutter_launcher_icons」という便利なpluginがあるのですが、何も準備せずに画像を作成すると、エラーになる場合があります。 私が遭遇したエラーの対処法です。
flutter_launcher_iconsについて
上記リンクの通りです。アイコン画像を作成して、コマンドをえいやすると各デバイス用サイズのアイコンファイルをよろしく作成してくれます。楽ですね。(ありがてえ)
エラー
なんですが、私がやってCodeMaicでビルドしたら以下のエラーが発生しました。
"Error Domain=ITunesConnectionOperationErrorDomain Code=1091 \"Invalid App Store Icon. The App Store Icon in the asset catalog in 'Runner.app' can't be transparent nor contain an alpha channel.\" UserInfo={NSLocalizedRecoverySuggestion=Invalid App Store Icon. The App Store Icon in the asset catalog in 'Runner.app' can't be transparent nor contain an alpha channel., NSLocalizedDescription=Invalid App Store Icon. The App Store Icon in the asset catalog in 'Runner.app' can't be transparent nor contain an alpha channel., NSLocalizedFailureReason=App Store operation failed.}"
エラーをよくよむとわかるのですが、「can't be transparent nor contain an alpha channel」ということで、画像にalphaが入っているとだめなようで、flutter_launcher_iconsはalphaの除去はしてくれないようです。
issueはあがっていました。
対処方法は、こちらの通り。 stackoverflow.com
macの場合の簡易的なやり方ですが、
画像をプレビューで開く
メニュー -> ファイル -> 書き出す
- アルファのチェックをはずして保存
で大丈夫です。
※デザイナーさんに作ってもらった画像であれば、再出力をお願いする方が確実です。
まとめ
flutter_launcher_iconsを使ったお手軽にやる場合でも、アルファの除去はしてくれないので、正しい仕様を把握して書き出しておきましょう(自戒)