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

[firebase_core]: Firebase.initializeApp works locally on flutter web, but throws exception on deploy done in AWS Amplify #13006

Open
1 task done
JacoNeto opened this issue Jun 26, 2024 · 3 comments
Assignees
Labels
blocked: customer-response Waiting for customer response, e.g. more information was requested. platform: web Issues / PRs which are specifically for web. plugin: core type: bug Something isn't working

Comments

@JacoNeto
Copy link

JacoNeto commented Jun 26, 2024

Is there an existing issue for this?

  • I have searched the existing issues.

Which plugins are affected?

Core

Which platforms are affected?

Web

Description

After running the flutterfire configure command on terminal, setting all platforms and calling the Firebase.initializeApp method, The flutter app is initializing normally on android, ios and web locally. However, when the web app is deployed to production, it does not initialize. I am not using Firebase Hosting. Both the deploy and hosting of the web app are being done at AWS Amplify.

I caught the following exception in the browser console:

An error occurred configuring Firebase: PlatformException(channel-error, Unable to establish connection on channel., null, null)

All dependencies are up to date. I checked if the firebase_options.dart file contained the correct credentials, which it did.

Reproducing the issue

1- Run flutterfire configure in the root of your flutter project
2- select platforms android, ios and web
3- Call

try {
      await Firebase.initializeApp(
        options: DefaultFirebaseOptions.currentPlatform,
      );
      FirebaseAnalytics analytics = FirebaseAnalytics.instance;
      await analytics.logAppOpen();
      material.WidgetsFlutterBinding.ensureInitialized();
} on Exception catch (e) {
      print('An error occurred configuring Firebase: $e');
}

in your main.dart file

4- run flutter build web on a terminal
5- deploy the web build (not to firebase hosting, but to AWS Amplify)
6- open the app in any web browser and open console tab
7- it will show the following exception:

An error occurred configuring Firebase: PlatformException(channel-error, Unable to establish connection on channel., null, null)

Firebase Core version

3.1.1

Flutter Version

3.22.2

Relevant Log Output

An error occurred configuring Firebase: PlatformException(channel-error, Unable to establish connection on channel., null, null)

Flutter dependencies

Expand Flutter dependencies snippet
Dart SDK 3.4.3
Flutter SDK 3.22.2
sprint_wave_fe 2.0.5+26

dependencies:
- amplify_auth_cognito 1.8.0 [amplify_analytics_pinpoint amplify_analytics_pinpoint_dart amplify_auth_cognito_dart amplify_core amplify_flutter amplify_secure_storage async flutter meta path plugin_platform_interface]
- amplify_flutter 1.8.0 [amplify_core amplify_secure_storage aws_common collection flutter meta]
- amplify_storage_s3 1.8.0 [amplify_core amplify_db_common amplify_storage_s3_dart aws_common flutter meta path_provider]
- auto_scroll_text 0.0.7 [flutter]
- bcrypt 1.1.3
- cached_network_image 3.3.1 [cached_network_image_platform_interface cached_network_image_web flutter flutter_cache_manager octo_image]
- clipboard 0.1.3 [flutter]
- community_material_icon 5.9.55 [flutter]
- country_ip 3.0.0 [http]
- custom_refresh_indicator 3.1.0 [flutter meta]
- dartz 0.10.1
- dio 5.4.1 [async http_parser meta path]
- dotted_border 2.1.0 [flutter path_drawing]
- expand_widget 3.1.1 [flutter]
- firebase_analytics 11.1.0 [firebase_analytics_platform_interface firebase_analytics_web firebase_core firebase_core_platform_interface flutter]
- firebase_core 3.1.1 [firebase_core_platform_interface firebase_core_web flutter meta]
- fl_chart 0.66.2 [equatable flutter]
- flutter 0.0.0 [characters collection material_color_utilities meta vector_math sky_engine]
- flutter_flavor 3.1.3 [flutter]
- flutter_keyboard_visibility 6.0.0 [meta flutter_keyboard_visibility_platform_interface flutter_keyboard_visibility_linux flutter_keyboard_visibility_macos flutter_keyboard_visibility_web flutter_keyboard_visibility_windows flutter]
- flutter_localizations 0.0.0 [flutter intl characters clock collection material_color_utilities meta path vector_math]
- flutter_native_splash 2.4.0 [args flutter flutter_web_plugins html image meta path universal_io xml yaml ansicolor]
- flutter_svg 2.0.10+1 [flutter http vector_graphics vector_graphics_codec vector_graphics_compiler]
- flutter_widget_from_html_core 0.15.1 [csslib flutter html logging]
- go_router 13.2.0 [collection flutter flutter_web_plugins logging meta]
- google_fonts 6.1.0 [flutter http path_provider crypto]
- icons_launcher 2.1.7 [args image path universal_io yaml]
- image_picker 1.0.7 [flutter image_picker_android image_picker_for_web image_picker_ios image_picker_linux image_picker_macos image_picker_platform_interface image_picker_windows]
- in_app_review 2.0.9 [flutter in_app_review_platform_interface]
- infinite_scroll_pagination 4.0.0 [flutter flutter_staggered_grid_view sliver_tools]
- intl 0.19.0 [clock meta path]
- mime 1.0.5
- nested 1.0.0 [flutter]
- package_info_plus 6.0.0 [ffi flutter flutter_web_plugins http meta path package_info_plus_platform_interface web win32]
- pin_code_fields 8.0.1 [flutter]
- provider 6.1.1 [collection flutter nested]
- share_plus 9.0.0 [cross_file meta mime flutter flutter_web_plugins share_plus_platform_interface file url_launcher_web url_launcher_windows url_launcher_linux url_launcher_platform_interface ffi web win32]
- shared_preferences 2.2.2 [flutter shared_preferences_android shared_preferences_foundation shared_preferences_linux shared_preferences_platform_interface shared_preferences_web shared_preferences_windows]
- translator 1.0.0 [http]
- url_launcher 6.2.5 [flutter url_launcher_android url_launcher_ios url_launcher_linux url_launcher_macos url_launcher_platform_interface url_launcher_web url_launcher_windows]
- web 0.5.1
- webview_flutter 4.7.0 [flutter webview_flutter_android webview_flutter_platform_interface webview_flutter_wkwebview]
- whatsapp_unilink 2.1.0

dev dependencies:
- flutter_lints 2.0.3 [lints]
- flutter_test 0.0.0 [flutter test_api matcher path fake_async clock stack_trace vector_math leak_tracker_flutter_testing async boolean_selector characters collection leak_tracker leak_tracker_testing material_color_utilities meta source_span stream_channel string_scanner term_glyph vm_service]

transitive dependencies:
- _flutterfire_internals 1.3.38 [collection firebase_core firebase_core_platform_interface flutter meta]
- amplify_analytics_pinpoint 1.8.0 [amplify_analytics_pinpoint_dart amplify_core amplify_db_common amplify_secure_storage aws_common device_info_plus flutter meta package_info_plus path_provider]
- amplify_analytics_pinpoint_dart 0.3.8 [amplify_core amplify_db_common_dart amplify_secure_storage_dart aws_common aws_signature_v4 built_collection built_value collection drift intl meta path smithy smithy_aws uuid]
- amplify_auth_cognito_dart 0.10.13 [amplify_analytics_pinpoint_dart amplify_core amplify_secure_storage_dart async aws_common aws_signature_v4 built_collection built_value clock collection convert crypto ffi fixnum http intl js json_annotation meta oauth2 path smithy smithy_aws stream_transform uuid win32 win32_registry worker_bee]
- amplify_core 1.8.0 [async aws_common aws_signature_v4 collection graphs intl json_annotation logging meta retry stack_trace uuid]
- amplify_db_common 0.3.6 [amplify_db_common_dart drift flutter path path_provider]
- amplify_db_common_dart 0.3.7 [amplify_core async aws_common drift meta path sqlite3]
- amplify_secure_storage 0.4.4 [amplify_secure_storage_dart async file flutter meta path path_provider path_provider_windows]
- amplify_secure_storage_dart 0.4.4 [async aws_common built_collection built_value ffi file js meta path win32 worker_bee]
- amplify_storage_s3_dart 0.3.11 [amplify_core amplify_db_common_dart async aws_common aws_signature_v4 built_collection built_value drift fixnum json_annotation meta path smithy smithy_aws]
- ansicolor 2.0.2
- archive 3.6.1 [crypto path]
- args 2.4.2
- async 2.11.0 [collection meta]
- aws_common 0.6.5 [async built_collection built_value collection http2 js json_annotation logging meta mime os_detect path stream_transform uuid]
- aws_signature_v4 0.5.2 [async aws_common collection convert crypto json_annotation meta path]
- boolean_selector 2.1.1 [source_span string_scanner]
- built_collection 5.1.1
- built_value 8.8.1 [built_collection collection fixnum meta]
- cached_network_image_platform_interface 4.0.0 [flutter flutter_cache_manager]
- cached_network_image_web 1.2.0 [cached_network_image_platform_interface flutter flutter_cache_manager]
- characters 1.3.0
- clock 1.1.1
- collection 1.18.0
- convert 3.1.1 [typed_data]
- crclib 3.0.0 [meta tuple]
- cross_file 0.3.4+1 [meta web]
- crypto 3.0.3 [typed_data]
- csslib 1.0.0 [source_span]
- device_info_plus 10.1.0 [device_info_plus_platform_interface ffi file flutter flutter_web_plugins meta web win32 win32_registry]
- device_info_plus_platform_interface 7.0.0 [flutter meta plugin_platform_interface]
- drift 2.14.1 [async convert collection js meta stream_channel sqlite3 path]
- equatable 2.0.5 [collection meta]
- fake_async 1.3.1 [clock collection]
- ffi 2.1.0
- file 7.0.0 [meta path]
- file_selector_linux 0.9.2+1 [cross_file file_selector_platform_interface flutter]
- file_selector_macos 0.9.3+3 [cross_file file_selector_platform_interface flutter]
- file_selector_platform_interface 2.6.2 [cross_file flutter http plugin_platform_interface]
- file_selector_windows 0.9.3+1 [cross_file file_selector_platform_interface flutter]
- firebase_analytics_platform_interface 4.1.0 [_flutterfire_internals firebase_core flutter meta plugin_platform_interface]
- firebase_analytics_web 0.5.8 [_flutterfire_internals firebase_analytics_platform_interface firebase_core firebase_core_web flutter flutter_web_plugins]
- firebase_core_platform_interface 5.1.0 [collection flutter flutter_test meta plugin_platform_interface]
- firebase_core_web 2.17.2 [firebase_core_platform_interface flutter flutter_web_plugins meta web]
- fixnum 1.1.0
- flutter_cache_manager 3.3.1 [clock collection file flutter http path path_provider rxdart sqflite uuid]
- flutter_keyboard_visibility_linux 1.0.0 [flutter_keyboard_visibility_platform_interface flutter]
- flutter_keyboard_visibility_macos 1.0.0 [flutter_keyboard_visibility_platform_interface flutter]
- flutter_keyboard_visibility_platform_interface 2.0.0 [flutter meta plugin_platform_interface]
- flutter_keyboard_visibility_web 2.0.0 [flutter_keyboard_visibility_platform_interface flutter_web_plugins flutter]
- flutter_keyboard_visibility_windows 1.0.0 [flutter_keyboard_visibility_platform_interface flutter]
- flutter_plugin_android_lifecycle 2.0.17 [flutter]
- flutter_staggered_grid_view 0.7.0 [flutter]
- flutter_web_plugins 0.0.0 [flutter characters collection material_color_utilities meta vector_math]
- graphs 2.3.1 [collection]
- html 0.15.4 [csslib source_span]
- http 1.2.1 [async http_parser meta web]
- http2 2.3.0
- http_parser 4.0.2 [collection source_span string_scanner typed_data]
- image 4.2.0 [archive meta xml]
- image_picker_android 0.8.9+3 [flutter flutter_plugin_android_lifecycle image_picker_platform_interface]
- image_picker_for_web 3.0.2 [flutter flutter_web_plugins image_picker_platform_interface mime]
- image_picker_ios 0.8.9+1 [flutter image_picker_platform_interface]
- image_picker_linux 0.2.1+1 [file_selector_linux file_selector_platform_interface flutter image_picker_platform_interface]
- image_picker_macos 0.2.1+1 [file_selector_macos file_selector_platform_interface flutter image_picker_platform_interface]
- image_picker_platform_interface 2.9.3 [cross_file flutter http plugin_platform_interface]
- image_picker_windows 0.2.1+1 [file_selector_platform_interface file_selector_windows flutter image_picker_platform_interface]
- in_app_review_platform_interface 2.0.5 [flutter url_launcher plugin_platform_interface platform]
- js 0.6.7 [meta]
- json_annotation 4.8.1 [meta]
- leak_tracker 10.0.4 [clock collection meta path vm_service]
- leak_tracker_flutter_testing 3.0.3 [flutter leak_tracker leak_tracker_testing matcher meta]
- leak_tracker_testing 3.0.1 [leak_tracker matcher meta]
- lints 2.1.1
- logging 1.2.0
- matcher 0.12.16+1 [async meta stack_trace term_glyph test_api]
- material_color_utilities 0.8.0 [collection]
- meta 1.12.0
- oauth2 2.0.2 [collection crypto http http_parser]
- octo_image 2.0.0 [flutter]
- os_detect 2.0.1
- package_info_plus_platform_interface 2.0.1 [flutter meta plugin_platform_interface]
- path 1.9.0
- path_drawing 1.0.1 [vector_math meta path_parsing flutter]
- path_parsing 1.0.1 [vector_math meta]
- path_provider 2.1.2 [flutter path_provider_android path_provider_foundation path_provider_linux path_provider_platform_interface path_provider_windows]
- path_provider_android 2.2.2 [flutter path_provider_platform_interface]
- path_provider_foundation 2.3.2 [flutter path_provider_platform_interface]
- path_provider_linux 2.2.1 [ffi flutter path path_provider_platform_interface xdg_directories]
- path_provider_platform_interface 2.1.2 [flutter platform plugin_platform_interface]
- path_provider_windows 2.2.1 [ffi flutter path path_provider_platform_interface win32]
- petitparser 6.0.2 [meta]
- platform 3.1.4
- plugin_platform_interface 2.1.8 [meta]
- retry 3.1.2
- rxdart 0.27.7
- share_plus_platform_interface 4.0.0 [cross_file flutter meta mime plugin_platform_interface path_provider uuid]
- shared_preferences_android 2.2.1 [flutter shared_preferences_platform_interface]
- shared_preferences_foundation 2.3.5 [flutter shared_preferences_platform_interface]
- shared_preferences_linux 2.3.2 [file flutter path path_provider_linux path_provider_platform_interface shared_preferences_platform_interface]
- shared_preferences_platform_interface 2.3.2 [flutter plugin_platform_interface]
- shared_preferences_web 2.3.0 [flutter flutter_web_plugins shared_preferences_platform_interface web]
- shared_preferences_windows 2.3.2 [file flutter path path_provider_platform_interface path_provider_windows shared_preferences_platform_interface]
- shelf 1.4.1 [async collection http_parser path stack_trace stream_channel]
- sky_engine 0.0.99
- sliver_tools 0.2.12 [flutter]
- smithy 0.6.4 [async aws_common built_collection built_value collection convert crypto fixnum http_parser intl json_annotation meta path retry shelf typed_data xml]
- smithy_aws 0.6.3 [aws_common aws_signature_v4 built_collection built_value collection convert crclib crypto intl json_annotation meta path smithy xml]
- source_span 1.10.0 [collection path term_glyph]
- sprintf 7.0.0
- sqflite 2.3.3+1 [flutter sqflite_common path]
- sqflite_common 2.5.4 [synchronized path meta]
- sqlite3 2.4.0 [collection ffi js meta path]
- stack_trace 1.11.1 [path]
- stream_channel 2.1.2 [async]
- stream_transform 2.1.0
- string_scanner 1.2.0 [source_span]
- synchronized 3.1.0+1
- term_glyph 1.2.1
- test_api 0.7.0 [async boolean_selector collection meta source_span stack_trace stream_channel string_scanner term_glyph]
- tuple 2.0.2
- typed_data 1.3.2 [collection]
- universal_io 2.2.2 [collection meta typed_data]
- url_launcher_android 6.3.0 [flutter url_launcher_platform_interface]
- url_launcher_ios 6.2.5 [flutter url_launcher_platform_interface]
- url_launcher_linux 3.1.1 [flutter url_launcher_platform_interface]
- url_launcher_macos 3.1.0 [flutter url_launcher_platform_interface]
- url_launcher_platform_interface 2.3.2 [flutter plugin_platform_interface]
- url_launcher_web 2.3.1 [flutter flutter_web_plugins url_launcher_platform_interface web]
- url_launcher_windows 3.1.1 [flutter url_launcher_platform_interface]
- uuid 4.3.3 [crypto sprintf meta fixnum]
- vector_graphics 1.1.11+1 [flutter http vector_graphics_codec]
- vector_graphics_codec 1.1.11+1
- vector_graphics_compiler 1.1.11+1 [args meta path_parsing xml vector_graphics_codec path]
- vector_math 2.1.4
- vm_service 14.2.1
- webview_flutter_android 3.15.0 [flutter webview_flutter_platform_interface]
- webview_flutter_platform_interface 2.10.0 [flutter meta plugin_platform_interface]
- webview_flutter_wkwebview 3.12.0 [flutter path webview_flutter_platform_interface]
- win32 5.2.0 [ffi]
- win32_registry 1.1.2 [ffi win32]
- worker_bee 0.2.4 [async aws_common built_collection built_value collection js meta path stack_trace stream_channel stream_transform]
- xdg_directories 1.0.4 [meta path]
- xml 6.5.0 [collection meta petitparser]
- yaml 3.1.2 [collection source_span string_scanner]

Additional context and comments

No response

@JacoNeto JacoNeto added Needs Attention This issue needs maintainer attention. type: bug Something isn't working labels Jun 26, 2024
@JacoNeto JacoNeto changed the title [firebase_core]: Firebase.initializeApp works locally on flutter web, but throws exception on deploy [firebase_core]: Firebase.initializeApp works locally on flutter web, but throws exception on deploy to AWS Amplify Jun 26, 2024
@JacoNeto JacoNeto changed the title [firebase_core]: Firebase.initializeApp works locally on flutter web, but throws exception on deploy to AWS Amplify [firebase_core]: Firebase.initializeApp works locally on flutter web, but throws exception on deploy done in AWS Amplify Jun 26, 2024
@TarekkMA TarekkMA added plugin: core platform: web Issues / PRs which are specifically for web. labels Jun 27, 2024
@TarekkMA
Copy link
Contributor

@JacoNeto Thank you for reporting this issue. Did you try using Firebase Hosting? Did it work? I'm curious if it would work while AWS Amplify does not.

@TarekkMA TarekkMA self-assigned this Jun 27, 2024
@TarekkMA TarekkMA added blocked: customer-response Waiting for customer response, e.g. more information was requested. and removed Needs Attention This issue needs maintainer attention. labels Jun 27, 2024
@russellwheatley
Copy link
Member

This should be placed before initializing Firebase app as well:

material.WidgetsFlutterBinding.ensureInitialized();

@JacoNeto
Copy link
Author

JacoNeto commented Jul 2, 2024

This should be placed before initializing Firebase app as well:

material.WidgetsFlutterBinding.ensureInitialized();

Thank you for the answer @russellwheatley, but this is already being done. As I said, it's working well in android, ios and web locally.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
blocked: customer-response Waiting for customer response, e.g. more information was requested. platform: web Issues / PRs which are specifically for web. plugin: core type: bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants