firebase / flutterfire

🔥 A collection of Firebase plugins for Flutter apps.
https://firebase.google.com/docs/flutter/setup
BSD 3-Clause "New" or "Revised" License
8.7k stars 3.97k forks source link

Uncaught FirebaseError: Firebase: No Firebase App '[DEFAULT]' has been created - call Firebase App.initializeApp() (app/no-app). at Object.f [as app] (https://www.gstatic.com/firebasejs/8.2.1/firebase-app.js:1:16867) #4599

Closed bgwissam closed 3 years ago

bgwissam commented 3 years ago

Trying to build flutterFire web app is always causing the same error. Below is my index.html and main.dart files that are handling the initialization of the app.

Steps to reproduce

Index.html file

Steps to reproduce the behavior:

<meta charset="UTF-8" />
<meta content="IE=Edge" http-equiv="X-UA-Compatible" />
<meta name="description" content="A new Flutter project." />

<!-- iOS meta tags & icons -->
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="apple-mobile-web-app-status-bar-style" content="black" />
<meta name="apple-mobile-web-app-title" content="web_product_unitrade" />
<link rel="apple-touch-icon" href="icons/Icon-192.png" />

<!-- Favicon -->
<link rel="icon" type="image/png" href="favicon.png" />

<title>web_product_unitrade</title>
<link rel="manifest" href="manifest.json" />
<script>
  if ("serviceWorker" in navigator) {
    window.addEventListener("flutter-first-frame", function () {
      navigator.serviceWorker.register("flutter_service_worker.js");
    });
  }
</script>
<!-- Firebase App (the core Firebase SDK) is always required and must be listed first -->
<script src="https://www.gstatic.com/firebasejs/8.2.1/firebase-app.js"></script>

<!-- If you enabled Analytics in your project, add the Firebase SDK for Analytics -->
<script src="https://www.gstatic.com/firebasejs/8.2.1/firebase-analytics.js"></script>

<!-- Add Firebase products that you want to use -->
<script src="https://www.gstatic.com/firebasejs/7.8.0/firebase-auth.js"></script>
<script src="https://www.gstatic.com/firebasejs/7.17.1/firebase-firestore.js"></script>
<script src="https://www.gstatic.com/firebasejs/8.2.1/firebase-storage.js"></script>
<!-- <script src="/lib/configuration/firebase-config.js"></script> -->

<script type="module">
  // import { firebaseConfig } from "/lib/configuration/firebase-config.js";
  // Initialize Firebase
  var firebaseConfig = {
  //data removed for security reasons
  };

  firebase.initializeApp(firebaseConfig);
  //firebase.analytics();
</script>

<script src="main.dart.js" type="application/javascript"></script>

main.dart

Future main() async {
// WidgetsFlutterBinding.ensureInitialized();
// await Firebase.initializeApp();
// developer.log('${Firebase.apps.length}', name: 'main.dart');
// FlutterError.onError = (FlutterErrorDetails details) {
// FlutterError.dumpErrorToConsole(details);
// };
runApp(App());
}

class App extends StatefulWidget {
_AppState createState() => _AppState();
}

class _AppState extends State {
final Future _initialization = Firebase.initializeApp();

@override
Widget build(BuildContext context) {
return FutureBuilder(
future: _initialization,
builder: (context, snapshot) {
if (snapshot.hasError) {
return Container(
child: Text('An Error Occurred'),
);
}
if (snapshot.connectionState == ConnectionState.done) {
return StreamProvider.value(
value: AuthService().user,
child: MaterialApp(
title: MAIN_TITLE,
debugShowCheckedModeBanner: false,
theme: ThemeData(
primarySwatch: Colors.amber,
accentColor: Colors.amber[200]),
home: MyHomePage(
title: HOME_PAGE,
),
routes: <String, WidgetBuilder>{
'/home': (BuildContext context) => new Wrapper(),
},
),
);
}
return MaterialApp(
title: MAIN_TITLE,
debugShowCheckedModeBanner: false,
theme: ThemeData(
primarySwatch: Colors.red, accentColor: Colors.red[200]),
home: Loading(),
);
});
}
}

Expected behavior

When running the web app in debug mode, it works properly without any errors, when running in release mode the above error is always showing. I need to find a way to get a more detailed error in release mode to know exactly what's causing the issue?

Flutter doctor

Doctor summary (to see all details, run flutter doctor -v):
[√] Flutter (Channel dev, 1.26.0-1.0.pre, on Microsoft Windows [Version 10.0.18363.1256], locale en-US)       
[√] Android toolchain - develop for Android devices (Android SDK version 28.0.3)
[√] Chrome - develop for the web
[√] Android Studio (version 4.1.0)
[√] IntelliJ IDEA Community Edition (version 2019.2)
[√] IntelliJ IDEA Community Edition (version 2020.1)
[√] IntelliJ IDEA Ultimate Edition (version 2020.2)
[√] VS Code (version 1.52.1)
[√] Connected device (1 available)

• No issues found!

Flutter dependencies

Run flutter pub deps -- --style=compact and paste the output below:

Click To Expand ``` Dart SDK 2.12.0-141.0.dev Flutter SDK 1.26.0-1.0.pre web_product_unitrade 1.0.0+1 |-- cached_network_image 2.5.0 | |-- flutter... | |-- flutter_cache_manager 2.1.0 | | |-- clock... | | |-- file... | | |-- flutter... | | |-- http... | | |-- image 2.1.19 | | | |-- archive... | | | |-- meta... | | | '-- xml 4.5.1 | | | |-- collection... | | | |-- convert... | | | |-- meta... | | | '-- petitparser 3.1.0 | | | '-- meta... | | |-- path... | | |-- path_provider 1.6.24 | | | |-- flutter... | | | |-- path_provider_linux 0.0.1+2 | | | | |-- flutter... | | | | |-- path... | | | | |-- path_provider_platform_interface... | | | | '-- xdg_directories 0.1.2 | | | | |-- meta... | | | | |-- path... | | | | '-- process... | | | |-- path_provider_macos 0.0.4+6 | | | | '-- flutter... | | | |-- path_provider_platform_interface 1.0.4 | | | | |-- flutter... | | | | |-- meta... | | | | |-- platform... | | | | '-- plugin_platform_interface... | | | '-- path_provider_windows 0.0.4+3 | | | |-- ffi 0.1.3 | | | |-- flutter... | | | |-- meta... | | | |-- path... | | | |-- path_provider_platform_interface... | | | '-- win32 1.7.4 | | | '-- ffi... | | |-- pedantic 1.10.0-nullsafety.3 | | |-- rxdart 0.25.0 | | |-- sqflite 1.3.2+1 | | | |-- flutter... | | | |-- path... | | | '-- sqflite_common 1.0.2+1 | | | |-- meta... | | | |-- path... | | | '-- synchronized 2.2.0+2 | | '-- uuid 2.2.2 | | |-- convert... | | '-- crypto... | '-- octo_image 0.3.0 | |-- flutter... | '-- flutter_blurhash 0.5.0 | |-- flutter... | '-- meta... |-- cloud_firestore 0.14.4 | |-- cloud_firestore_platform_interface 2.2.1 | | |-- collection... | | |-- firebase_core... | | |-- flutter... | | |-- meta... | | '-- plugin_platform_interface... | |-- cloud_firestore_web 0.2.1+2 | | |-- cloud_firestore_platform_interface... | | |-- firebase_core... | | |-- firebase_core_web... | | |-- flutter... | | |-- flutter_web_plugins... | | |-- http_parser... | | |-- js... | | '-- meta... | |-- firebase_core... | |-- firebase_core_platform_interface... | |-- flutter... | |-- meta... | '-- quiver... |-- cupertino_icons 1.0.2 |-- file_picker 1.4.2 | '-- flutter... |-- firebase 7.3.3 | |-- http 0.12.2 | | |-- http_parser... | | |-- path... | | '-- pedantic... | |-- http_parser 3.1.4 | | |-- charcode... | | |-- collection... | | |-- source_span... | | |-- string_scanner... | | '-- typed_data... | '-- js 0.6.3-nullsafety.3 |-- firebase_auth 0.18.4+1 | |-- firebase_auth_platform_interface 2.1.4 | | |-- firebase_core... | | |-- flutter... | | |-- meta... | | '-- plugin_platform_interface... | |-- firebase_auth_web 0.3.2+3 | | |-- firebase_auth_platform_interface... | | |-- firebase_core... | | |-- firebase_core_web... | | |-- flutter... | | |-- flutter_web_plugins... | | |-- http_parser... | | |-- intl 0.16.1 | | | '-- path... | | |-- js... | | '-- meta... | |-- firebase_core... | |-- firebase_core_platform_interface... | |-- flutter... | '-- meta... |-- firebase_core 0.5.3 | |-- firebase_core_platform_interface 2.1.0 | | |-- flutter... | | |-- meta... | | |-- plugin_platform_interface 1.0.3 | | | '-- meta... | | '-- quiver... | |-- firebase_core_web 0.2.1+1 | | |-- firebase_core_platform_interface... | | |-- flutter... | | |-- flutter_web_plugins 0.0.0 | | | |-- characters... | | | |-- collection... | | | |-- flutter... | | | |-- js... | | | |-- meta... | | | |-- typed_data... | | | '-- vector_math... | | |-- js... | | '-- meta... | |-- flutter... | |-- meta... | '-- quiver 2.1.5 | |-- matcher... | '-- meta... |-- firebase_storage 5.2.0 | |-- firebase_core... | |-- firebase_core_platform_interface... | |-- firebase_storage_platform_interface 1.0.2 | | |-- collection... | | |-- firebase_core... | | |-- flutter... | | |-- meta... | | '-- plugin_platform_interface... | |-- firebase_storage_web 0.1.1+1 | | |-- async... | | |-- crypto... | | |-- firebase_core... | | |-- firebase_core_web... | | |-- firebase_storage_platform_interface... | | |-- flutter... | | |-- flutter_web_plugins... | | |-- http... | | |-- js... | | '-- meta... | |-- flutter... | '-- quiver... |-- flutter 0.0.0 | |-- characters 1.1.0-nullsafety.5 | |-- collection 1.15.0-nullsafety.5 | |-- meta 1.3.0-nullsafety.6 | |-- sky_engine 0.0.99 | |-- typed_data 1.3.0-nullsafety.5 | | '-- collection... | '-- vector_math 2.1.0-nullsafety.5 |-- flutter_pdfview 1.0.4 | '-- flutter... |-- flutter_spinkit 4.1.2+1 | '-- flutter... |-- flutter_test 0.0.0 | |-- async 2.5.0-nullsafety.3 | | '-- collection... | |-- boolean_selector 2.1.0-nullsafety.3 | | |-- source_span... | | '-- string_scanner... | |-- characters... | |-- charcode 1.2.0-nullsafety.3 | |-- clock 1.1.0-nullsafety.3 | |-- collection... | |-- fake_async 1.2.0-nullsafety.3 | | |-- clock... | | '-- collection... | |-- flutter... | |-- matcher 0.12.10-nullsafety.3 | | '-- stack_trace... | |-- meta... | |-- path 1.8.0-nullsafety.3 | |-- source_span 1.8.0-nullsafety.4 | | |-- charcode... | | |-- collection... | | |-- path... | | '-- term_glyph... | |-- stack_trace 1.10.0-nullsafety.6 | | '-- path... | |-- stream_channel 2.1.0-nullsafety.3 | | '-- async... | |-- string_scanner 1.1.0-nullsafety.3 | | |-- charcode... | | '-- source_span... | |-- term_glyph 1.2.0-nullsafety.3 | |-- test_api 0.2.19-nullsafety.6 | | |-- async... | | |-- boolean_selector... | | |-- collection... | | |-- matcher... | | |-- meta... | | |-- path... | | |-- source_span... | | |-- stack_trace... | | |-- stream_channel... | | |-- string_scanner... | | '-- term_glyph... | |-- typed_data... | '-- vector_math... |-- image_picker 0.6.7+17 | |-- flutter... | |-- flutter_plugin_android_lifecycle 1.0.11 | | '-- flutter... | '-- image_picker_platform_interface 1.1.1 | |-- flutter... | |-- http... | |-- meta... | '-- plugin_platform_interface... |-- image_whisperer 0.11.1 | '-- exifdart 0.7.0+3 |-- integration_test 0.9.2+2 | |-- _fe_analyzer_shared 12.0.0 | | '-- meta... | |-- analyzer 0.40.6 | | |-- _fe_analyzer_shared... | | |-- args... | | |-- cli_util... | | |-- collection... | | |-- convert... | | |-- crypto... | | |-- glob... | | |-- meta... | | |-- package_config... | | |-- path... | | |-- pub_semver... | | |-- source_span... | | |-- watcher... | | '-- yaml... | |-- archive 2.0.13 | | |-- args... | | |-- crypto... | | '-- path... | |-- args 1.6.0 | |-- async... | |-- boolean_selector... | |-- characters... | |-- charcode... | |-- cli_util 0.2.0 | | '-- path... | |-- clock... | |-- collection... | |-- convert 2.1.1 | | |-- charcode... | | '-- typed_data... | |-- coverage 0.14.2 | | |-- args... | | |-- logging... | | |-- package_config... | | |-- path... | | |-- source_maps... | | |-- stack_trace... | | '-- vm_service... | |-- crypto 2.1.5 | | |-- collection... | | |-- convert... | | '-- typed_data... | |-- fake_async... | |-- file 6.0.0-nullsafety.4 | | |-- meta... | | '-- path... | |-- flutter... | |-- flutter_driver 0.0.0 | | |-- archive... | | |-- args... | | |-- async... | | |-- boolean_selector... | | |-- characters... | | |-- charcode... | | |-- clock... | | |-- collection... | | |-- convert... | | |-- crypto... | | |-- fake_async... | | |-- file... | | |-- flutter... | | |-- flutter_test... | | |-- fuchsia_remote_debug_protocol 0.0.0 | | | |-- archive... | | | |-- args... | | | |-- async... | | | |-- boolean_selector... | | | |-- charcode... | | | |-- clock... | | | |-- collection... | | | |-- convert... | | | |-- crypto... | | | |-- fake_async... | | | |-- file... | | | |-- flutter_driver... | | | |-- flutter_test... | | | |-- json_rpc_2... | | | |-- matcher... | | | |-- meta... | | | |-- path... | | | |-- platform... | | | |-- process... | | | |-- source_span... | | | |-- stack_trace... | | | |-- stream_channel... | | | |-- string_scanner... | | | |-- sync_http... | | | |-- term_glyph... | | | |-- test_api... | | | |-- typed_data... | | | |-- vector_math... | | | |-- vm_service... | | | |-- web_socket_channel... | | | '-- webdriver... | | |-- json_rpc_2 2.2.2 | | | |-- stack_trace... | | | '-- stream_channel... | | |-- matcher... | | |-- meta... | | |-- path... | | |-- platform 3.0.0-nullsafety.4 | | |-- process 4.0.0-nullsafety.4 | | | |-- file... | | | |-- path... | | | '-- platform... | | |-- source_span... | | |-- stack_trace... | | |-- stream_channel... | | |-- string_scanner... | | |-- sync_http... | | |-- term_glyph... | | |-- test_api... | | |-- typed_data... | | |-- vector_math... | | |-- vm_service... | | |-- web_socket_channel 1.1.0 | | | |-- async... | | | |-- crypto... | | | '-- stream_channel... | | '-- webdriver... | |-- flutter_test... | |-- glob 1.2.0 | | |-- async... | | |-- collection... | | |-- node_io... | | |-- path... | | |-- pedantic... | | '-- string_scanner... | |-- io 0.3.4 | | |-- charcode... | | |-- meta... | | |-- path... | | '-- string_scanner... | |-- js... | |-- logging 0.11.4 | |-- matcher... | |-- meta... | |-- node_interop 1.2.1 | | '-- js... | |-- node_io 1.1.1 | | |-- node_interop... | | '-- path... | |-- package_config 1.9.3 | | |-- charcode... | | '-- path... | |-- path... | |-- pool 1.5.0-nullsafety.3 | | |-- async... | | '-- stack_trace... | |-- pub_semver 1.4.4 | | '-- collection... | |-- source_map_stack_trace 2.1.0-nullsafety.4 | | |-- path... | | |-- source_maps... | | '-- stack_trace... | |-- source_maps 0.10.10-nullsafety.3 | | '-- source_span... | |-- source_span... | |-- stack_trace... | |-- stream_channel... | |-- string_scanner... | |-- sync_http 0.2.0 | |-- term_glyph... | |-- test_api... | |-- test_core 0.3.12-nullsafety.9 | | |-- analyzer... | | |-- args... | | |-- async... | | |-- boolean_selector... | | |-- collection... | | |-- coverage... | | |-- glob... | | |-- io... | | |-- matcher... | | |-- meta... | | |-- package_config... | | |-- path... | | |-- pedantic... | | |-- pool... | | |-- source_map_stack_trace... | | |-- source_maps... | | |-- source_span... | | |-- stack_trace... | | |-- stream_channel... | | |-- test_api... | | |-- vm_service... | | '-- yaml... | |-- typed_data... | |-- vector_math... | |-- vm_service 5.5.0 | | '-- meta... | |-- watcher 0.9.7+15 | | |-- async... | | |-- path... | | '-- pedantic... | |-- webdriver 2.1.2 | | |-- archive... | | |-- matcher... | | |-- path... | | |-- stack_trace... | | '-- sync_http... | '-- yaml 2.2.1 | |-- charcode... | |-- collection... | |-- source_span... | '-- string_scanner... '-- provider 4.3.2+3 |-- collection... |-- flutter... '-- nested 0.0.4 '-- flutter... ```

markusaksli-nc commented 3 years ago

Hi @bgwissam Does it also not work if you use the recommended version 7.20.0 JS SDK imports in index.html? Thank you

bgwissam commented 3 years ago

Hi @bgwissam Does it also not work if you use the recommended version 7.20.0 JS SDK imports in index.html? Thank you

Hi @markusaksli-nc yes, I tried changing the version to 7.20.0 and I did try other versions as well, but the same issue is still happening. The problem is that main.dart class isn't executing is not executed in the deployed state. I think running the webpage isn't passing the index.html file.

I've been trying to find a way to get a more detailed error from the scripts in index.html but so far not successful, let me know if there's a way?

bgwissam commented 3 years ago

The issue was with the flutter sdk, I downloaded a new sdk and re-created the project.