如何解决异常错误:名称为[DEFAULT]的FirebaseApp不存在?

时间:2019-12-17 23:44:02

标签: firebase flutter dart visual-studio-code

这是发生异常的地方:

 @override
  Future<FirebaseUser> getCurrentUser() async {
    FirebaseUser user = await _firebaseAuth.currentUser();
    return user;
  }

确切的错误是:

 Exception has occurred.
PlatformException (PlatformException(error, FirebaseApp with name [DEFAULT] doesn't exist. , null))

我的Flutter Doctor输出:

[flutter] flutter doctor -v
[√] Flutter (Channel stable, v1.12.13+hotfix.5, on Microsoft Windows [Version 10.0.17763.914], locale en-US)
    • Flutter version 1.12.13+hotfix.5 at D:\src\flutter
    • Framework revision 27321ebbad (7 days ago), 2019-12-10 18:15:01 -0800
    • Engine revision 2994f7e1e6
    • Dart version 2.7.0

[!] Android toolchain - develop for Android devices (Android SDK version 29.0.2)
    • Android SDK at C:\Users\jcdos\AppData\Local\Android\sdk
    • Android NDK location not configured (optional; useful for native profiling support)
    • Platform android-29, build-tools 29.0.2
    • Java binary at: D:\Android Studio\jre\bin\java
    • Java version OpenJDK Runtime Environment (build 1.8.0_202-release-1483-b03)
    ! Some Android licenses not accepted.  To resolve this, run: flutter doctor --android-licenses

[!] Android Studio (version 3.5)
    • Android Studio at D:\Android Studio
    X Flutter plugin not installed; this adds Flutter specific functionality.
    X Dart plugin not installed; this adds Dart specific functionality.
    • Java version OpenJDK Runtime Environment (build 1.8.0_202-release-1483-b03)

[!] Connected device
    ! No devices available

! Doctor found issues in 3 categories.
exit code 0

这是我的调试控制台:

E/flutter ( 6562): #40     SingleChildRenderObjectElement.mount 
package:flutter/…/widgets/framework.dart:5445
E/flutter ( 6562): #41     Element.inflateWidget 
package:flutter/…/widgets/framework.dart:3194
E/flutter ( 6562): #42     Element.updateChild 
package:flutter/…/widgets/framework.dart:2988
E/flutter ( 6562): #43     ComponentElement.performRebuild 
package:flutter/…/widgets/framework.dart:4243
E/flutter ( 6562): #44     Element.rebuild 
package:flutter/…/widgets/framework.dart:3947
E/flutter ( 6562): #
√ Built build\app\outputs\apk\debug\app-debug.apk.

我已经尝试寻找其他来源来修复该错误,但是没有任何效果。我从应用程序gradle中删除了应用插件:“ com.google.gms.google-services”,因为这导致了我其他问题。并删除了此问题,正如我发现的消息灵通所说的那样,它已经在其他地方被调用了。

如果我保留com.google.gms.google-services,则会收到此错误,这会阻止该应用程序同时在模拟器中运行:

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:processDebugGoogleServices'.
> No matching client found for package name 'com.example.testapp

2 个答案:

答案 0 :(得分:0)

在Android Studio中运行该应用程序,它应该显示一些错误或需要更新的文件,例如build.gradle文件中的文件。另外,您还需要com.google.gms.google-services作为Firebase。

答案 1 :(得分:0)

将以下行添加到您的android / app / build.gradle文件中:

apply plugin: 'com.google.gms.google-services'

enter image description here