0

If I follow the flutterfire docs to install the flutterfire_core library and the realtime_db library, it seems I can connect to my remote firebase database when building for Chrome, but not for macOS (M1 2021 MB Pro).

The simplest example I can give you is this (myApp is unchanged from the default flutter create):

import 'package:flutter/material.dart';
import 'package:firebase_core/firebase_core.dart';
import 'package:firebase_database/firebase_database.dart';
import 'firebase_options.dart';



void main() async {
  WidgetsFlutterBinding.ensureInitialized();
  await Firebase.initializeApp(
    options: DefaultFirebaseOptions.currentPlatform,
  );

  await FirebaseDatabase.instance.ref().update({
    "name": "Derek",
  }).then((_) {
        print("hello");
    })
    .catchError((error) {
        print("uhoh");
    });

  runApp(const MyApp());
}

This compiles with no errors on my local machine (for neither macOS nor Chrome). When building for chrome, it was able to update the remote, but not when building for macOS (it just hangs, no UI is loaded, no print statements complete). (Along the way, I did update my macOS build settings to 10.15, because I was being yelled about having things set to 10.11. When I have tried this in the past, with 10.12, things didn't work either.)

I have also tried to clone the example here, and it "works" (with warnings) on my machine for the Chrome build but not the macOS build.

Right now, the errors I get when I compile the github example code on MacOS are

[ERROR:flutter/lib/ui/ui_dart_state.cc(198)] Unhandled Exception: [core/duplicate-app] A Firebase App named "[DEFAULT]" already exists
#0      MethodChannelFirebase.initializeApp (package:firebase_core_platform_interface/src/method_channel/method_channel_firebase.dart:127:11)
<asynchronous suspension>
#1      Firebase.initializeApp (package:firebase_core/src/firebase.dart:40:31)
<asynchronous suspension>
#2      main (package:firebase_database_example/main.dart:29:3)
<asynchronous suspension>```. That seems unrelated to my current problem, but I tried it so I thought I would give it to you.

Thank you for any help you could send my way :-)


Output of ```flutter --version```:

```Flutter 3.0.1 • channel stable • https://github.com/flutter/flutter.git
Framework • revision fb57da5f94 (2 weeks ago) • 2022-05-19 15:50:29 -0700
Engine • revision caaafc5604
Tools • Dart 2.17.1 • DevTools 2.12.2

Output of flutterfire -v

0.2.2+2
jo la
  • 1
  • 1
  • You need to add the name just as follow: [A Firebase App named "[DEFAULT]" already exists](https://stackoverflow.com/a/71644195/18141665) – Rodrigo Bustillos Jun 03 '22 at 20:33

0 Answers0