LoginSignup
5
1

More than 3 years have passed since last update.

FlutterでFirebaseを初期化する時のエラー解消方法「Firebase has not been correctly initialized. 」

Last updated at Posted at 2021-05-17

Firebase初期化

firebaseがアプデしててハマったけど、一旦解決したので残しときます。

//main.dart
void main() async {
  WidgetsFlutterBinding.ensureInitialized();//2行目だけだとエラーになるので追加
  await Firebase.initializeApp(); // ここ大事!Firebase使うのに初期化しないとエラーになる
  runApp(MyApp());
}

エラー

実際は、上記のように書いても以下のようなエラーが出ました。

[core/not-initialized] Firebase has not been correctly initialized. Have you added the "GoogleService-Info.plist" file to the pr

解決方法

"GoogleService-Info.plist" をXcodeにドラッグアンドドロップで設定していましたが、
Xcode内でRunnerフォルダを選択して "Add files"から"GoogleService-Info.plist"を置くと何故か成功しました。
参考:https://stackoverflow.com/questions/45317777/could-not-find-a-valid-googleservice-info-plist-in-your-project

5
1
1

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
5
1