颤振+;Firebase | java.lang.IllegalStateException:名为[DEFAULT]的FirebaseApp不';不存在

颤振+;Firebase | java.lang.IllegalStateException:名为[DEFAULT]的FirebaseApp不';不存在,firebase,flutter,google-cloud-firestore,Firebase,Flutter,Google Cloud Firestore,我正试图通过将我的基本颤振应用程序连接到云Firestore(在Firebase中)来完成一个非常简单的练习 我已经按照有关设置的说明进行了操作。但是,我得到了以下错误 E/MethodChannel#plugins.flutter.io/cloud_firestore(13217): Failed to handle method call E/MethodChannel#plugins.flutter.io/cloud_firestore(13217): java.lang.IllegalS

我正试图通过将我的基本颤振应用程序连接到云Firestore(在Firebase中)来完成一个非常简单的练习

我已经按照有关设置的说明进行了操作。但是,我得到了以下错误

E/MethodChannel#plugins.flutter.io/cloud_firestore(13217): Failed to handle method call
E/MethodChannel#plugins.flutter.io/cloud_firestore(13217): java.lang.IllegalStateException: FirebaseApp with name [DEFAULT] doesn't exist.
我的颤振代码:

import 'package:flutter/material.dart';
import 'package:cloud_firestore/cloud_firestore.dart';

void main() => runApp(MyApp());

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
        title: 'Playground',
        home: Scaffold(
            appBar: AppBar(
              title: Text('Playground App'),
            ),
            body: Column(children: <Widget>[
              Text('Sup World?'),
            StreamBuilder(
              stream: Firestore.instance.collection('test').snapshots(),
              builder: (context, snapshot) {
                if (!snapshot.hasData) return const Text('Loading....');

                return Text('Loaded');
              },
            )
            ])));
  }
}
android\app\build.gradle文件中添加的依赖项和新行

dependencies {
    classpath 'com.android.tools.build:gradle:3.3.1'
    classpath 'com.google.gms:google-services:4.0.1'
}
dependencies {
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.2'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
    implementation 'com.google.firebase:firebase-core:16.0.1'
}

apply plugin: 'com.google.gms.google-services'
pubspec.yaml中的依赖项

dependencies:
  flutter:
    sdk: flutter
  intl: 0.15.7
  cloud_firestore: ^0.8.2
我还下载了google services.json文件并将其添加到android\app文件夹中

在Firestore db中,我有一个id为test的集合,其中包含一个文档

预期结果: 文本“Loaded”应显示在文本“Sup World?”

然而,我得到了上面的错误,它显示了文本“加载”


有人能帮我解决这个问题吗?

我也在GitHub上发布了这个。在项目上运行flutter clean,然后再次运行应用程序,为我修复了它

GitHub问题的url。

当我更新到更新的谷歌服务时,我遇到了这个错误


切换回
classpath'com.google.gms:google services:3.2.1'
,它开始工作正常。

如果您还添加了pubspec文件,这样我们就可以知道您是否在flatter pubspec.yaml中添加了firebase插件了!!并交叉检查您是否在项目级gradle中添加了类路径“com.google.gms:google services:3.0.0”。@Harshapulikollu-我已经用pubspec.yaml文件中的依赖项更新了线程。@Harshapulikollu-关于项目级gradle,您是指Flatter项目级的gradle文件吗?我没有,我是说在你的android项目级别/android/build.gradlefile@Harshapulikollu-是的,在里面。我已经在上面添加了它。把它放在这里,以防万一有用:依赖项{classpath'com.android.tools.build:gradle:3.3.1'classpath'com.google.gms:googleservices:4.0.1'}