缺少Pluginexception(缺少Pluginexception(在Channel plugins.flutter.io/firebase_core上找不到用于方法firebase#directizecore的实现)

发布于 2025-02-11 17:36:31 字数 1449 浏览 0 评论 0原文

import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:firebase_auth/firebase_auth.dart';
import 'package:flutter/material.dart';
import 'package:todo_firebase/auth/authscreen.dart';
import 'package:firebase_core/firebase_core.dart';
import 'package:todo_firebase/screens/home.dart';

void main() async {
  WidgetsFlutterBinding.ensureInitialized();

  await Firebase.initializeApp();
  //initilization of Firebase app

  // other Firebase service initialization

  runApp(MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: StreamBuilder(
        stream: FirebaseAuth.instance.authStateChanges(),
        builder: (context, usersnapshot) {
          if (usersnapshot.hasData) {
            return Home();
          } else {
            return AuthScreen();
          }
        },
      ),
      debugShowCheckedModeBanner: false,
      theme: ThemeData(brightness: Brightness.light, primaryColor: Colors.blue),
      // ignore: dead_code
    );
  }
}

这是我的主要代码。 我在“等待firebase.initializeapp()”上获得以下输出: 缺少Pluginexception(缺少PlugineXception(在Channel插件上找到firebase#priniseizecore的实现,在Channel plugins.flutter.io/firebase_core上找到))

我正在尝试制作每日任务应用程序,但是每当我使用vscode执行它时,它就会构建一个看起来为空白的Windows应用程序。我已经在LIB(身份验证和主页)​​,main.dart和pubspec.yaml的不同部分中编写了整个代码。请提供解决错误的方法,并使我的应用程序起作用。

import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:firebase_auth/firebase_auth.dart';
import 'package:flutter/material.dart';
import 'package:todo_firebase/auth/authscreen.dart';
import 'package:firebase_core/firebase_core.dart';
import 'package:todo_firebase/screens/home.dart';

void main() async {
  WidgetsFlutterBinding.ensureInitialized();

  await Firebase.initializeApp();
  //initilization of Firebase app

  // other Firebase service initialization

  runApp(MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: StreamBuilder(
        stream: FirebaseAuth.instance.authStateChanges(),
        builder: (context, usersnapshot) {
          if (usersnapshot.hasData) {
            return Home();
          } else {
            return AuthScreen();
          }
        },
      ),
      debugShowCheckedModeBanner: false,
      theme: ThemeData(brightness: Brightness.light, primaryColor: Colors.blue),
      // ignore: dead_code
    );
  }
}

This is my main.dart code.
I get the following output at 'await Firebase.initializeApp()':
MissingPluginException (MissingPluginException(No implementation found for method Firebase#initializeCore on channel plugins.flutter.io/firebase_core))

I'm trying to make a daily task app but whenever I execute it using VSCode, it builds a Windows Application that appears blank. I've written the whole code in the different sections of lib (authentication and homepage), main.dart, and pubspec.yaml but it is not executing. Kindly provide the method to fix the error, and make my app work.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

骑趴 2025-02-18 17:36:32

今天早上有这个问题。我花了几个小时来弄清楚。现在一切都在起作用!

我做了什么?我尝试清理项目,删除iOS文件并运行flutter Create。几次没有运气...将我的头发拔出!

什么修复了?

  • 在Xcode中更新您的GEMS
  • 删除iOS文件(LOL)
  • 删除“派生数据”,并在Xcode

Run中清洁构建文件夹Flutter Clean在您的项目中,然后运行Flutter Pub Cache Repair < /代码>

然后,您需要使用最新版本的Firebase Core等手动更新PubSpec.yaml。是的。是的,请确保先删除锁定文件,然后手动更新依赖项。 不要运行 Flutter Pub升级。不起作用..只需手动添加它们:(

这就是我手动添加到我的pubspec.yaml的内容:

cloud_firestore: ^3.2.1
firebase_core: ^1.19.1
firebase_storage: ^10.3.1
firebase_auth: ^3.4.1
firebase_messaging: ^11.4.4

Had this issue this morning.. What a problem it was! Took me a few hours to figure out. Everything is working now though!

What did I do? I tried cleaning my project out, deleted ios file and ran flutter create . a few times with no luck... Pulled my hair out!

What fixed it?

  • update your gems
  • delete ios file for the 5th time (LOL)
  • delete "derived data" in xcode and clean build folder in xcode

run flutter clean inside your project and then run flutter pub cache repair

Then you need to manually update your pubspec.yaml with the latest version of firebase core, etc. Yes make sure you delete lock file first then manually update the dependencies. DO NOT run flutter pub upgrade. Won't work.. Just manually add them in :(

This is what I manually added into my pubspec.yaml:

cloud_firestore: ^3.2.1
firebase_core: ^1.19.1
firebase_storage: ^10.3.1
firebase_auth: ^3.4.1
firebase_messaging: ^11.4.4
绮筵 2025-02-18 17:36:32

我最终尝试了所有内容,包括禁用缩放,但是对我没有任何帮助。在与另一个项目进行比较之后,我发现显然flutter Pub很奇怪,并且使用1.xx作为版本约束(即使我通过Flutter Pub添加)。

更改pubspec.yaml中的依赖项为2.xx工作:

dependencies:
    ....
    firebase_core: ^2.7.1

请确保您使用的是: https://pub.dev/packages/firebase_core

如果您面临类似的问题,也可以为其他Firebase插件软件包做同样的事情。

I ended up trying everything including disabling minify, however nothing worked for me. After comparing to another project I found out that apparently flutter pub was being weird and was using 1.x.x as the version constraint(even though I was adding the dependency through flutter pub add).

Changing the dependency in pubspec.yaml to 2.x.x worked:

dependencies:
    ....
    firebase_core: ^2.7.1

Please ensure that you are using the correct version from: https://pub.dev/packages/firebase_core.

You can also do the same for other firebase plugin packages if you are facing a similar issue with them.

水水月牙 2025-02-18 17:36:32

最新的Firebase_core版本1.19.0似乎有问题
尝试使用以前的版本:

firebase_core: ^1.18.0

至少这为我解决了问题。

There seems to be a problem with the latest firebase_core version 1.19.0
Try to use the previous version:

firebase_core: ^1.18.0

At least this solved the problem for me.

我的黑色迷你裙 2025-02-18 17:36:32

首先,检查所有应用程序在运行时不得在任何设备上运行,然后停止它,然后
将这些命令解散到终端
颤动清洁
然后
flutter Pub获取

然后运行您的项目

First of check all your app must not be running on any device If running then stop it and then
Fire these command into terminal
Flutter clean
Then
Flutter pub get

Then run your project

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文