もやぶろ

moyashidaisukeのブログだからもやぶろ。フリーランスのエンジニアのダイスケです。QOLあげて色々楽しくチャレンジして良く生きたい。プログラム関連とかギター関連とか旅行関連とか色々。

【Flutter】flutter_launcher_iconsを使ってアプリアイコンを設定したら「Invalid App Store Icon.」エラーの時の対応

概要

Flutterでアプリアイコンを作成する場合、「flutter_launcher_icons」という便利なpluginがあるのですが、何も準備せずに画像を作成すると、エラーになる場合があります。 私が遭遇したエラーの対処法です。

flutter_launcher_iconsについて

qiita.com

qiita.com

上記リンクの通りです。アイコン画像を作成して、コマンドをえいやすると各デバイス用サイズのアイコンファイルをよろしく作成してくれます。楽ですね。(ありがてえ)

エラー

なんですが、私がやって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はあがっていました。

github.com

対処方法は、こちらの通り。 stackoverflow.com

macの場合の簡易的なやり方ですが、

  1. 画像をプレビューで開く

  2. メニュー -> ファイル -> 書き出す

f:id:moyashidaisuke:20190927215435p:plain

  1. アルファのチェックをはずして保存

f:id:moyashidaisuke:20190927215501p:plain

で大丈夫です。

※デザイナーさんに作ってもらった画像であれば、再出力をお願いする方が確実です。

growthhackjournal.com

まとめ

flutter_launcher_iconsを使ったお手軽にやる場合でも、アルファの除去はしてくれないので、正しい仕様を把握して書き出しておきましょう(自戒)