缺少插件异常(在频道 plugins.flutter.io/firebase_core 上没有找到方法 firebase#initializecore 的实现)

时间:2021-02-18 11:53:16

标签: android firebase flutter flutter-desktop

错误描述 我在 Windows 桌面上运行我的 flutter 应用程序 我在 android studio 中使用主频道以便在桌面上运行它。 我已将 Firebase 集成到我的应用程序中,并且登录注册工作正常,但是当我尝试从云 Firestore 添加或获取数据时,错误似乎是“没有创建 Firebase 应用程序‘[DEFAULT]’ - 调用 Firebase Flutter 和 Firebase 中的 .initializeApp()" ,通过添加

解决
ds = tf.data.Dataset.from_tensor_slices((X_train.to_dict(orient='list'), y_train))
bagged_sample = []
for i in range(desired_size): 
  bagged_sample.append(ds.take(1))
  ds = ds.shuffle(len(ds))
#combine bagged_sample somehow ...

到我的应用程序。 但是在添加这个之后我得到了这个错误:

void main()
async
{
   WidgetsFlutterBinding.ensureInitialized();
   await Firebase.initializeApp();
   // if (USE_FIRESTORE_EMULATOR) {
   //   FirebaseFirestore.instance.settings = Settings(
   //       host: 'localhost:8080', sslEnabled: false, persistenceEnabled: false);
   // }
  runApp(MyApp());
}

这是我无法解决的错误。出现此错误后,我的应用程序 GUI 不显示。 我尝试了互联网上提供的多种解决方案,但没有一个对我有用。 我在下面提供了 flutter doctor 和 pubspec,请查看并帮助我解决这个问题。 提前致谢 颤振医生

Launching lib\main.dart on Windows in debug mode...
Building Windows application...
Debug service listening on ws://127.0.0.1:14281/b7FohxM2yN4=/ws
Syncing files to device Windows...
[ERROR:flutter/lib/ui/ui_dart_state.cc(186)] Unhandled Exception: MissingPluginException(No implementation found for method Firebase#initializeCore on channel plugins.flutter.io/firebase_core)
#0      MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:156:7)
<asynchronous suspension>
#1      MethodChannel.invokeListMethod (package:flutter/src/services/platform_channel.dart:344:35)
<asynchronous suspension>
#2      MethodChannelFirebase._initializeCore (package:firebase_core_platform_interface/src/method_channel/method_channel_firebase.dart:30:22)
<asynchronous suspension>
#3      MethodChannelFirebase.initializeApp (package:firebase_core_platform_interface/src/method_channel/method_channel_firebase.dart:75:7)
<asynchronous suspension>
#4      Firebase.initializeApp (package:firebase_core/src/firebase.dart:43:9)
<asynchronous suspension>
#5      main (package:res_ds/main.dart:17:4)
<asynchronous suspension>

Pubspec.yaml

flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[√] Flutter (Channel master, 1.27.0-2.0.pre.67, on Microsoft Windows [Version 10.0.19041.804], locale 
en-US)
[!] Android toolchain - develop for Android devices (Android SDK version 30.0.1)
    X Android license status unknown.
      Run `flutter doctor --android-licenses` to accept the SDK licenses.
      See https://flutter.dev/docs/get-started/install/windows#android-setup for more details.
[√] Visual Studio - develop for Windows (Visual Studio Community 2019 16.8.4)
[√] Android Studio (version 4.1.0)
[√] VS Code (version 1.52.1)
[√] Connected device (1 available)

! Doctor found issues in 1 category.

1 个答案:

答案 0 :(得分:1)

Flutter Firebase 插件 do not currently support Windows,这就是在 Windows 上运行时没有插件实现的原因。