skip to Main Content

I was trying to integrate firebase in Flutter with FlutterFire.
I have done very steps on documentation yet i couldnot start the app.

I tried Searching the error on StackOverflow yet could not find any hints on solution.
What exactly am i missing?

c:drumkillergoogle_maps_in_flutter>flutterfire configure
i Found 3 Firebase projects.
✔ Select a Firebase project to configure your Flutter application with · g-map-8f66c (g-map)
✔ Which platforms should your configuration support (use arrow keys & space to select)? · android, ios, macos, web
i Firebase android app com.example.google_maps_in_flutter is not registered on Firebase project g-map-8f66c.
i Registered a new Firebase android app on Firebase project g-map-8f66c.
i Firebase ios app com.example.googleMapsInFlutter is not registered on Firebase project g-map-8f66c.
i Registered a new Firebase ios app on Firebase project g-map-8f66c.
i Firebase macos app com.example.googleMapsInFlutter registered.
i Firebase web app google_maps_in_flutter (web) is not registered on Firebase project g-map-8f66c.
i Registered a new Firebase web app on Firebase project g-map-8f66c.

Firebase configuration file libfirebase_options.dart generated successfully with the following Firebase apps:

Platform  Firebase App Id
web       1:178984749635:web:3e7e105df5e73d519da2f6
android   1:178984749635:android:2c82e4a8770b873e9da2f6
ios       1:178984749635:ios:07715f151dbe0db39da2f6
macos     1:178984749635:ios:07715f151dbe0db39da2f6

Learn more about using this file and next steps from the documentation:
 > https://firebase.google.com/docs/flutter/setup

c:drumkillergoogle_maps_in_flutter>

Then some files were generated.Then in my main.dart

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

void main() async {
  WidgetsFlutterBinding.ensureInitialized();
  await Firebase.initializeApp(options: DefaultFirebaseOptions.currentPlatform);
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: const MyHomePage(title: 'Flutter Demo Home Page'),
    );
  }
}

class MyHomePage extends StatefulWidget {
  const MyHomePage({super.key, required this.title});

  final String title;

  @override
  State<MyHomePage> createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  int _counter = 0;

  void _incrementCounter() {
    setState(() {
      _counter++;
    });
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text(widget.title),
      ),
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
            const Text(
              'You have pushed the button this many times:',
            ),
            Text(
              '$_counter',
              style: Theme.of(context).textTheme.headline4,
            ),
          ],
        ),
      ),
      floatingActionButton: FloatingActionButton(
        onPressed: _incrementCounter,
        tooltip: 'Increment',
        child: const Icon(Icons.add),
      ),
    );
  }
}

The Error shown when I run: flutter run is

Launching libmain.dart on M2101K7AG in debug mode...
/C:/src/flutter/.pub-cache/hosted/pub.dartlang.org/firebase_core_platform_interface-4.5.1/lib/src/method_channel/method_channel_firebase.dart:40:38: Error: Type 'PigeonInitializeResponse' not found.
  void _initializeFirebaseAppFromMap(PigeonInitializeResponse response) {
                                     ^^^^^^^^^^^^^^^^^^^^^^^^
/C:/src/flutter/.pub-cache/hosted/pub.dartlang.org/firebase_core_platform_interface-4.5.1/lib/src/pigeon/mocks.dart:5:10: Error: Type 'PigeonInitializeResponse' not found.
  Future<PigeonInitializeResponse> initializeApp(
         ^^^^^^^^^^^^^^^^^^^^^^^^
/C:/src/flutter/.pub-cache/hosted/pub.dartlang.org/firebase_core_platform_interface-4.5.1/lib/src/pigeon/mocks.dart:22:15: Error: Type 'PigeonInitializeResponse' not found.
  Future<List<PigeonInitializeResponse?>> initializeCore() async {
              ^^^^^^^^^^^^^^^^^^^^^^^^
/C:/src/flutter/.pub-cache/hosted/pub.dartlang.org/firebase_core_platform_interface-4.5.1/lib/src/pigeon/test_api.dart:47:10: Error: Type 'PigeonInitializeResponse' not found.
  Future<PigeonInitializeResponse> initializeApp(
         ^^^^^^^^^^^^^^^^^^^^^^^^
/C:/src/flutter/.pub-cache/hosted/pub.dartlang.org/firebase_core_platform_interface-4.5.1/lib/src/pigeon/test_api.dart:49:15: Error: Type 'PigeonInitializeResponse' not found.
  Future<List<PigeonInitializeResponse?>> initializeCore();
              ^^^^^^^^^^^^^^^^^^^^^^^^
/C:/src/flutter/.pub-cache/hosted/pub.dartlang.org/firebase_core_platform_interface-4.5.1/lib/src/method_channel/method_channel_firebase.dart:29:10: Error: 'PigeonInitializeResponse' isn't a type.
    List<PigeonInitializeResponse?> apps = await api.initializeCore();
         ^^^^^^^^^^^^^^^^^^^^^^^^
/C:/src/flutter/.pub-cache/hosted/pub.dartlang.org/firebase_core_platform_interface-4.5.1/lib/src/method_channel/method_channel_firebase.dart:33:15: Error: 'PigeonInitializeResponse' isn't a type.
        .cast<PigeonInitializeResponse>()
              ^^^^^^^^^^^^^^^^^^^^^^^^
/C:/src/flutter/.pub-cache/hosted/pub.dartlang.org/firebase_core_platform_interface-4.5.1/lib/src/method_channel/method_channel_firebase.dart:40:38: Error: 'PigeonInitializeResponse' isn't a type.
  void _initializeFirebaseAppFromMap(PigeonInitializeResponse response) {
                                     ^^^^^^^^^^^^^^^^^^^^^^^^
/C:/src/flutter/.pub-cache/hosted/pub.dartlang.org/firebase_core_platform_interface-4.5.1/lib/src/pigeon/mocks.dart:9:12: Error: The method 
'PigeonInitializeResponse' isn't defined for the class 'MockFirebaseApp'.
 - 'MockFirebaseApp' is from 'package:firebase_core_platform_interface/src/pigeon/mocks.dart' ('/C:/src/flutter/.pub-cache/hosted/pub.dartlang.org/firebase_core_platform_interface-4.5.1/lib/src/pigeon/mocks.dart').
Try correcting the name to the name of an existing method, or defining a method named 'PigeonInitializeResponse'.
    return PigeonInitializeResponse(
           ^^^^^^^^^^^^^^^^^^^^^^^^
/C:/src/flutter/.pub-cache/hosted/pub.dartlang.org/firebase_core_platform_interface-4.5.1/lib/src/pigeon/mocks.dart:24:7: Error: The method 
'PigeonInitializeResponse' isn't defined for the class 'MockFirebaseApp'.
 - 'MockFirebaseApp' is from 'package:firebase_core_platform_interface/src/pigeon/mocks.dart' ('/C:/src/flutter/.pub-cache/hosted/pub.dartlang.org/firebase_core_platform_interface-4.5.1/lib/src/pigeon/mocks.dart').
Try correcting the name to the name of an existing method, or defining a method named 'PigeonInitializeResponse'.
      PigeonInitializeResponse(
      ^^^^^^^^^^^^^^^^^^^^^^^^
/C:/src/flutter/.pub-cache/hosted/pub.dartlang.org/firebase_core_platform_interface-4.5.1/lib/src/pigeon/test_api.dart:21:25: Error: 'PigeonInitializeResponse' isn't a type.
    } else if (value is PigeonInitializeResponse) {
                        ^^^^^^^^^^^^^^^^^^^^^^^^
/C:/src/flutter/.pub-cache/hosted/pub.dartlang.org/firebase_core_platform_interface-4.5.1/lib/src/pigeon/test_api.dart:36:16: Error: The getter 'PigeonInitializeResponse' isn't defined for the class '_TestFirebaseCoreHostApiCodec'.
 - '_TestFirebaseCoreHostApiCodec' is from 'package:firebase_core_platform_interface/src/pigeon/test_api.dart' ('/C:/src/flutter/.pub-cache/hosted/pub.dartlang.org/firebase_core_platform_interface-4.5.1/lib/src/pigeon/test_api.dart').
Try correcting the name to the name of an existing getter, or defining a getter or field named 'PigeonInitializeResponse'.
        return PigeonInitializeResponse.decode(readValue(buffer)!);
               ^^^^^^^^^^^^^^^^^^^^^^^^
/C:/src/flutter/.pub-cache/hosted/pub.dartlang.org/firebase_core_platform_interface-4.5.1/lib/src/pigeon/test_api.dart:71:17: Error: 'PigeonInitializeResponse' isn't a type.
          final PigeonInitializeResponse output =
                ^^^^^^^^^^^^^^^^^^^^^^^^
/C:/src/flutter/.pub-cache/hosted/pub.dartlang.org/firebase_core_platform_interface-4.5.1/lib/src/pigeon/test_api.dart:86:22: Error: 'PigeonInitializeResponse' isn't a type.
          final List<PigeonInitializeResponse?> output =
                     ^^^^^^^^^^^^^^^^^^^^^^^^


FAILURE: Build failed with an exception.

* Where:
Script 'C:srcflutterpackagesflutter_toolsgradleflutter.gradle' line: 1159

* What went wrong:
Execution failed for task ':app:compileFlutterBuildDebug'.
> Process 'command 'C:srcflutterbinflutter.bat'' finished with non-zero exit value 1

* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 24s
Running Gradle task 'assembleDebug'...                             25.5s
Exception: Gradle task assembleDebug failed with exit code 1

Files that were added Screen Shots:

enter image description here

Error Screen Shot:

enter image description here

My pubspec.yaml

enter image description here

My flutter doctor:::

Doctor summary (to see all details, run flutter doctor -v):
[√] Flutter (Channel stable, 3.3.2, on Microsoft Windows [Version 10.0.19043.2130], locale en-US)
[√] Android toolchain - develop for Android devices (Android SDK version 32.1.0-rc1)
[√] Chrome - develop for the web
[√] Visual Studio - develop for Windows (Visual Studio Community 2022 17.2.2)
[√] Android Studio (version 2021.2)
[√] VS Code (version 1.72.2)
[√] Connected device (4 available)
[√] HTTP Host Availability

• No issues found!

What i did was:

 1. Created a flutter Project in firebase console
 2. Set upped the flutter Fire
 3. created a new flutter project
 4. ran flutterfire configure in terminal
 5. added firebase_core in pubspec.yaml
 6. added  await Firebase.initializeApp(options: DefaultFirebaseOptions.currentPlatform,
); inside main.dart
 7. ran flutter run

2

Answers


  1. Chosen as BEST ANSWER

    So after Going through the most important thing, i.e. documentation of flutterFire, I found what was the mistake I was Doing.

    What i was missing was:

    flutterfire configure

    After adding firebase service, you must run flutterfire configure.

    So once I ran flutterfire configure everything started working.

    enter image description here

    The note section in the above Screen shot was helpful for me.

    For more: CLI | FlutterFire


  2. I cannot reproduce it but
    can you please try with

    await Firebase.initializeApp(); only

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search