Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

I just finished the first video and I get an error relating to firebase #4

Open
akshaybalaji123 opened this issue Sep 8, 2020 · 4 comments

Comments

@akshaybalaji123
Copy link

akshaybalaji123 commented Sep 8, 2020

@theindianappguy Launching lib\main.dart on sdk gphone x86 arm in debug mode...
Running Gradle task 'assembleDebug'...
✓ Built build\app\outputs\flutter-apk\app-debug.apk.
Installing build\app\outputs\flutter-apk\app.apk...
Waiting for sdk gphone x86 arm to report its views...
Debug service listening on ws://127.0.0.1:65280/yj6K69WaXFE=/ws
Syncing files to device sdk gphone x86 arm...

════════ Exception caught by widgets library
══╡ EXCEPTION CAUGHT BY WIDGETS LIBRARY ╞═══════════════════════════════════════════════════════════
The following FirebaseException was thrown building Builder:
[core/no-app] No Firebase App '[DEFAULT]' has been created - call Firebase.initializeApp()

The relevant error-causing widget was:
MaterialApp file:///C:/Users/aksha/Downloads/chatapp/chat_app_tutorial/lib/main.dart:13:12

When the exception was thrown, this was the stack:
#0 MethodChannelFirebase.app (package:firebase_core_platform_interface/src/method_channel/method_channel_firebase.dart:118:5)
#1 Firebase.app (package:firebase_core/src/firebase.dart:52:41)
#2 FirebaseAuth.instance (package:firebase_auth/src/firebase_auth.dart:37:47)
#3 new AuthMethods (package:chat_app_tutorial/services/auth.dart:6:42)
#4 new _SignupState (package:chat_app_tutorial/views/signup.dart:14:33)
#5 Signup.createState (package:chat_app_tutorial/views/signup.dart:7:33)
#6 new StatefulElement (package:flutter/src/widgets/framework.dart:4635:25)
#7 StatefulWidget.createElement (package:flutter/src/widgets/framework.dart:900:38)
... Normal element mounting (132 frames)
#139 Element.inflateWidget (package:flutter/src/widgets/framework.dart:3490:14)
#140 MultiChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:5991:32)
... Normal element mounting (258 frames)
#398 Element.inflateWidget (package:flutter/src/widgets/framework.dart:3490:14)
#399 Element.updateChild (package:flutter/src/widgets/framework.dart:3258:18)
#400 RenderObjectToWidgetElement._rebuild (package:flutter/src/widgets/binding.dart:1174:16)
#401 RenderObjectToWidgetElement.mount (package:flutter/src/widgets/binding.dart:1145:5)
#402 RenderObjectToWidgetAdapter.attachToRenderTree. (package:flutter/src/widgets/binding.dart:1087:17)
#403 BuildOwner.buildScope (package:flutter/src/widgets/framework.dart:2620:19)
#404 RenderObjectToWidgetAdapter.attachToRenderTree (package:flutter/src/widgets/binding.dart:1086:13)
#405 WidgetsBinding.attachRootWidget (package:flutter/src/widgets/binding.dart:927:7)
#406 WidgetsBinding.scheduleAttachRootWidget. (package:flutter/src/widgets/binding.dart:908:7)
(elided 11 frames from class _RawReceivePortImpl, class _Timer, dart:async, and dart:async-patch)

════════════════════════════════════════════════════════════════════════════════════════════════════
═══════════════════════════════════════════════════════
The following FirebaseException was thrown building Builder:
[core/no-app] No Firebase App '[DEFAULT]' has been created - call Firebase.initializeApp()

The relevant error-causing widget was:
MaterialApp file:///C:/Users/aksha/Downloads/chatapp/chat_app_tutorial/lib/main.dart:13:12
When the exception was thrown, this was the stack:
#0 MethodChannelFirebase.app (package:firebase_core_platform_interface/src/method_channel/method_channel_firebase.dart:118:5)
#1 Firebase.app (package:firebase_core/src/firebase.dart:52:41)
#2 FirebaseAuth.instance (package:firebase_auth/src/firebase_auth.dart:37:47)
#3 new AuthMethods (package:chat_app_tutorial/services/auth.dart:6:42)
#4 new _SignupState (package:chat_app_tutorial/views/signup.dart:14:33)
...

How do I fix this. It says that the error causing wdget was the MaterialApp(
) on the main.dart how do solve this? could I get help asap

@akshaybalaji123
Copy link
Author

Yes I did but now I am having a different problem.

My app does start the connection to Firebase but each time it says connection timed out and I cannot resolve it.

@akshaybalaji123
Copy link
Author

@theindianappguy do you use stream in this app? If we want to launch this app is there anyway to do this without stream??

@prasad7a
Copy link

Hello Akshay,
I recommend checking out this StackOverflow thread: https://stackoverflow.com/questions/63492211/no-firebase-app-default-has-been-created-call-firebase-initializeapp-in
There's more info on why this happened in the thread.
I used the fourth method because it was an easy implementation and it solved this issue instantly.

@schmelto
Copy link

schmelto commented Mar 18, 2021

The easiest way to solve this issue is to add those lines at your main.dart-file in your main-function

import 'package:flutter_chat_app/helper/authenticate.dart';
import 'package:firebase_core/firebase_core.dart';

void main() async {
  WidgetsFlutterBinding.ensureInitialized();
  await Firebase.initializeApp();
  runApp(MyApp());
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants