缺少文件附加错误颤动firebase
Posted
技术标签:
【中文标题】缺少文件附加错误颤动firebase【英文标题】:missing file attach error flutter firebase 【发布时间】:2021-05-26 13:41:38 【问题描述】:我在 Flutter 中将 firebase 添加到我的项目中,但项目没有打开。我收到此错误“MissingPluginException (MissingPluginException (No implementation found for method Firebase #initializeCore on channel plugins.flutter.io/firebase_core))”。以下是我为 firebase 添加的部分。你能帮帮我吗?
我添加到 pubspec.yaml 文件中:
dependencies:
flutter:
sdk: flutter
cupertino_icons: ^1.0.2
firebase_core: ^1.2.0
cloud_firestore: ^2.1.0
我还将它们添加到应用文件中的 build.gradle 中:
apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'
apply plugin: 'kotlin-android'
这也在正常的build.gradle中:
buildscript
ext.kotlin_version = '1.3.50'
repositories
google()
jcenter ()
dependencies
classpath 'com.android.tools.build:gradle:4.1.0'
classpath 'com.google.gms: google-services: 4.3.6'
classpath "org.jetbrains.kotlin: kotlin-gradle-plugin: $ kotlin_version"
allprojects
repositories
google()
jcenter ()
这是 main.dart:
import 'package:flutter/material.dart';
import 'package:firebase_core/firebase_core.dart';
import 'package:cloud_firestore/cloud_firestore.dart';
void main() async
WidgetsFlutterBinding.ensureInitialized();
await Firebase.initializeApp();
runApp(MaterialApp(
home: MyApp(),
debugShowCheckedModeBanner: false,
));
class MyApp extends StatelessWidget
// This widget is the root of your application.
final firestore = FirebaseFirestore.instance;
@override
Widget build(BuildContext context)
CollectionReference customerref = firestore.collection('Customers');
return Scaffold(
backgroundColor: Colors.white,
appBar: AppBar(
title: Text('MyColorGame'),
backgroundColor: Colors.black,
),
body: Center(
child: Container(
child: Text(
'$customerref.id',
style: TextStyle(fontSize: 24),
),
),
),
);
我也把json文件放到了app文件夹下。 我在哪里遗漏或错了?
【问题讨论】:
【参考方案1】:运行以下命令
flutter clean
flutter pub get
【讨论】:
我试过了,问题还是一样。以上是关于缺少文件附加错误颤动firebase的主要内容,如果未能解决你的问题,请参考以下文章