[英]MissingPluginException(No implementation found for method Firebase#initializeCore on channel plugins.flutter.io/firebase_core) on Android
[英]MissingPluginException (MissingPluginException(No implementation found for method Firebase#initializeCore on channel plugins.flutter.io/firebase_core)
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
);
}
}
这是我的 main.dart 代码。 我在'await Firebase.initializeApp()'得到以下输出: MissingPluginException (MissingPluginException(No implementation found for method Firebase#initializeCore on channel plugins.flutter.io/firebase_core))
我正在尝试制作一个日常任务应用程序,但每当我使用 VSCode 执行它时,它都会构建一个显示为空白的 Windows 应用程序。 我已经在 lib(身份验证和主页)、main.dart 和 pubspec.yaml 的不同部分编写了整个代码,但它没有执行。 请提供修复错误的方法,并使我的应用程序正常工作。
今天早上有这个问题..这是一个多么大的问题! 我花了几个小时才弄清楚。 不过现在一切正常!
我做了什么? 我尝试清理我的项目,删除 ios 文件并运行flutter create .
几次都没有运气......把我的头发拉了出来!
什么修好了?
在你的项目中运行flutter clean
,然后运行flutter pub cache repair
然后您需要使用最新版本的 firebase 核心等手动更新您的 pubspec.yaml。是的,请确保先删除锁定文件,然后手动更新依赖项。 不要运行flutter pub upgrade
。 行不通..只需手动添加它们:(
这是我手动添加到我的 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
首先你的应用程序没有在设备上运行如果运行然后停止它然后触发这些命令Flutter clean
然后Flutter pub get
然后运行你的项目
最新的firebase_core 1.19.0版本好像有问题尝试使用之前的版本:
firebase_core: ^1.18.0
至少这为我解决了问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.