![](/img/trans.png)
[英]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.