FlutterChatAppTutorial icon indicating copy to clipboard operation
FlutterChatAppTutorial copied to clipboard

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

Open akshaybalaji123 opened this issue 5 years ago • 4 comments

@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 avatar Sep 08 '20 10:09 akshaybalaji123

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 avatar Sep 08 '20 20:09 akshaybalaji123

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

akshaybalaji123 avatar Sep 09 '20 01:09 akshaybalaji123

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.

prasad7a avatar Sep 22 '20 17:09 prasad7a

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());
}

schmelto avatar Mar 18 '21 20:03 schmelto