How to solve Exception Error: FirebaseApp with name [DEFAULT] doesn't exist?

喜你入骨 提交于 2021-01-29 11:24:54

问题


Here is where the exception is happening:

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

The exact error is:

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

My Flutter Doctor Output:

[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

Here is my debug console:

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.

I've tried finding other sources to fix the error, but nothing works. I removed apply plugin: 'com.google.gms.google-services' from the app gradle as that was causing me other issues. And removing this fixed it, as the source I found said it gets called already somewhere else.

And if I keep the com.google.gms.google-services then I get this error which prevents the app from running in the emulator all together:

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

回答1:


Add below line into your android/app/build.gradle file:

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




回答2:


Run the application in Android studio it should show some of the errors or files that need to be updated like in the build.gradle files. Also, you need the com.google.gms.google-services for firebase.



来源:https://stackoverflow.com/questions/59383679/how-to-solve-exception-error-firebaseapp-with-name-default-doesnt-exist

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!