4
2

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.

”firebase_options.dart”が生成されない

Posted at

flutter codelabのfirebase get to know flutter step2のチュートリアル中にこの件でハマったので記録。

問題

flutterfire configureを実行しても”firebase_options.dart”が生成されない

flutterfire_cliによって、現在実装中アプリのファイル群を解析し、プラットフォーム依存に関する設定オプションファイルを生成する(勉強中のため理解が間違っているかもしれません)。
そのコマンドがflutterfire configure

ただし、私の環境(VS Code内)では実行してもうまく”firebase_options.dart”が生成されず、
これが影響したのかはfirebaseプロンプト(?)から実行しても同様にNG。
エラーは以下。

Unhandled exception:
FormatException: Unexpected character (at character 1)
#

解決に向けて

どうやら同様のケースはVS Codeに限らず発生しているようで、Stackover flowやflutterfire_cliのgitページにはいくつか同様のissueスレッドがある。
ただし、ズバリこれ、といった解決策は見当たらなかった。

  • VS Codeだと動かなかった
  • flutterfire_cliを再インストールしたら解決

など。

ここでは、これらの解決案を元に、私が解決までに試した一連を記す。 あくまで参考として留意されたし

解決までのステップ

  1. flutterfire_cliの再インストール

    • 自分はWindowsで試していたので、exeファイルを差し替え
      • バージョンに変更はなかったが、ファイルサイズが異なっていた
    • ただし、解決には至らず
  2. flutterfire_cliの再アクティベーション

    1. dart pub global deactivate flutterfire_cliを実行
    2. dart pub global activate flutterfire_cliを実行
      • 前提だが、2のactivateは既に実行済である。その上で再度アクティベーションすればよいかと考えたが、既にアクティベート済だから、deactivateしてから再実行しろとエラーが出るため、1→2と実行した。
        • このアクティベーションについては、全く理解できていない。
        • 実行するとflutterfireのコマンドが使えるようになる。この時に、色々と他モジュールなどの情報を収集しているようなので、ある程度環境依存のコマンドで、モジュールの入れ替えなどした場合には再アクティベーションが必要なものなのだろうか。
    • ただし、解決には至らず
  3. firebase --reauthを実行し、再認証。

  4. firebaseプロンプト(?)内でflutterfire configureを実行

    Firebase configuration file lib\firebase_options.dart generated successfully with the following Firebase apps:
    ...

解決!

以上だが、もちろん途中、都度firebaseプロンプト(?)内外でflutterfire configureを試して、NGだったため、上記ステップ一通り実行する必要があったのだと思うが、何が要因だったのかはわからない。
アクティベーション後は、firebaseプロンプト(?)内でなくても実行できるという理解だが、もしかしたらその理解が間違っていた?もしくは上手くアクティベーションができていない?
VS Codeではまだ試していない。

その後、チュートリアルの実行まで

この件とは違うが、android, iosのfirebase側のアプリケーション登録にミスがあったようで、flutterfire configureによって、自動的にfirebase側に登録してくれた。

Firebase android app com.example.gtk_flutter is not registered on Firebase project fir-flutter-codelab-12345.
Registered a new Firebase android app on Firebase project fir-flutter-codelab-12345.
Firebase ios app com.example.gtkFlutter is not registered on Firebase project fir-flutter-codelab-12345.
Registered a new Firebase ios app on Firebase project fir-flutter-codelab-12345.
Firebase macos app com.example.gtkFlutter is already registered.
Firebase web app gtk_flutter (web) is already registered.

image.png

実行結果

image.png

以上、終わり。

参考リンク

4
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
4
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?