Firebase не инициализируется в приложении Flutter. Он показывает, что тип «PigeonInitializeResponse» не найден.Android

Форум для тех, кто программирует под Android
Anonymous
Firebase не инициализируется в приложении Flutter. Он показывает, что тип «PigeonInitializeResponse» не найден.

Сообщение Anonymous »

Я пытался интегрировать Firebase во Flutter с FlutterFire.
Я проделал много шагов по документации, но не смог запустить приложение.
Я попробовал выполнить поиск ошибка в StackOverflow, но не удалось найти никаких подсказок по решению.
Что именно мне не хватает?


c:\drumkiller\google_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 lib\firebase_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:\drumkiller\google_maps_in_flutter>


Затем были созданы несколько файлов. Затем в моем 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 createState() => _MyHomePageState();
}

class _MyHomePageState extends State {
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: [
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),
),
);
}
}

При запуске отображается ошибка: запуск флаттера
Launching lib\main.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
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 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 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 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 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()
^^^^^^^^^^^^^^^^^^^^^^^^
/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 output =
^^^^^^^^^^^^^^^^^^^^^^^^

FAILURE: Build failed with an exception.

* Where:
Script 'C:\src\flutter\packages\flutter_tools\gradle\flutter.gradle' line: 1159

* What went wrong:
Execution failed for task ':app:compileFlutterBuildDebug'.
> Process 'command 'C:\src\flutter\bin\flutter.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

Добавленные файлы. Снимки экрана:
Изображение

Снимок экрана с ошибкой:
Изображение

Мой pubspec.yaml< /p>
Изображение

Мой флаттер-доктор:::
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!

Что я сделал:
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


Подробнее здесь: https://stackoverflow.com/questions/741 ... zeresponse

Вернуться в «Android»