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.51k stars 3.92k forks source link

[firebase_analytics]: Network upload failed (java.net.ConnectException) #12833

Closed AsimBhadra closed 3 weeks ago

AsimBhadra commented 1 month ago

Is there an existing issue for this?

Which plugins are affected?

Analytics

Which platforms are affected?

Android

Description

Events are not being logged in a Flutter app using Firebase Analytics. The following error message appears in adb logcat:

05-27 14:55:08.562 V/FA-SVC ( 6814): Network upload failed. Will retry later. code, error: 0, java.net.ConnectException: Failed to connect to app-measurement.com/[::]:443: btlq.run(:com.google.android.gms@242013038@24.20.13 (190400-633713831):154)

Attempted solutions:

  1. Verified Firebase configuration (GoogleService-Info.plist/google-services.json placement, project registration, Analytics enabled). Used flutterfire_cli.
  2. Confirmed stable internet connection (tried different networks)
  3. Checked Google Play Services version (matches device version)
  4. Resolved dependency conflicts (using flutter pub outdated and flutter pub upgrade)
  5. Cleaned and rebuilt the app (flutter clean and flutter build apk)
  6. Checked for firewall/proxy restrictions (if applicable)

Reproducing the issue

  1. Create a new Flutter project
  2. Add Firebase dependencies: firebase_core, firebase_analytics
  3. Configure Firebase
  4. Add a basic event logging method
import 'package:firebase_analytics/firebase_analytics.dart';

final FirebaseAnalytics analytics = FirebaseAnalytics();

void logEvent(String name, {Map<String, dynamic> parameters}) async {
await analytics.logEvent(name: name, parameters: parameters);
}

Firebase Core version

2.31.1

Flutter Version

3.19.6

Relevant Log Output

05-27 19:26:54.320 V/FA-SVC  ( 6814): Not stopping services. fetch, network, upload: false, true, false
05-27 19:26:54.322 V/FA-SVC  ( 6814): Uploading data. size: 585
05-27 19:26:54.344 V/FA-SVC  ( 6814): Network upload failed. Will retry later. code, error: 0, java.net.ConnectException: Failed to connect to app-measurement.com/[::]:443: btlq.run(:com.google.android.gms@242013038@24.20.13 (190400-633713831):154)
05-27 19:26:54.366 V/FA-SVC  ( 6814): Upload scheduled in approximately ms: 1800978
05-27 19:26:54.366 V/FA-SVC  ( 6814): Unscheduling upload
05-27 19:26:54.370 V/FA-SVC  ( 6814): Scheduling upload, millis: 1800978
05-27 19:26:54.372 V/FA-SVC  ( 6814): Stopping uploading service(s)
05-27 19:26:55.747 D/FA      (26095): Application going to the background
05-27 19:26:55.752 I/FA      (26095): Application backgrounded at: timestamp_millis: 1716817313745
05-27 19:26:58.789 V/FA      (26095): Inactivity, disconnecting from the service
05-27 19:29:00.665 V/FA      (27763): App measurement collection enabled
05-27 19:29:00.669 V/FA      (27763): App measurement enabled for app package, google app id: com.reddit.frontpage, 1:933360113277:android:2918df7f0aab10ef
05-27 19:29:00.671 I/FA      (27763): App measurement initialized, version: 94007

Flutter dependencies

Expand Flutter dependencies snippet
```yaml Dart SDK 3.4.1 Flutter SDK 3.22.1 wishmo 2.0.1+103 dependencies: - appsflyer_sdk 6.14.3 [flutter] - auto_route 7.8.4 [flutter path collection meta] - auto_size_text 3.0.0 [flutter] - connectivity_plus 5.0.1 [flutter flutter_web_plugins connectivity_plus_platform_interface js meta nm] - cupertino_icons 1.0.6 - custom_check_box 0.0.4 [flutter] - dio 5.3.3 [async http_parser meta path] - facebook_app_events 0.19.0 [flutter] - firebase_analytics 10.10.6 [firebase_analytics_platform_interface firebase_analytics_web firebase_core firebase_core_platform_interface flutter] - firebase_auth 4.19.6 [firebase_auth_platform_interface firebase_auth_web firebase_core firebase_core_platform_interface flutter meta] - firebase_core 2.31.1 [firebase_core_platform_interface firebase_core_web flutter meta] - firebase_dynamic_links 5.5.6 [firebase_core firebase_core_platform_interface firebase_dynamic_links_platform_interface flutter meta plugin_platform_interface] - firebase_messaging 14.9.3 [firebase_core firebase_core_platform_interface firebase_messaging_platform_interface firebase_messaging_web flutter meta] - flutter 0.0.0 [characters collection material_color_utilities meta vector_math sky_engine] - flutter_facebook_auth 6.0.2 [flutter flutter_facebook_auth_platform_interface flutter_facebook_auth_web facebook_auth_desktop] - flutter_local_notifications 17.0.0 [clock flutter flutter_local_notifications_linux flutter_local_notifications_platform_interface timezone] - flutter_riverpod 2.4.5 [collection flutter meta riverpod state_notifier] - flutter_smartlook 4.1.18 [flutter flutter_localizations vector_math] - flutter_svg 2.0.9 [flutter vector_graphics vector_graphics_codec vector_graphics_compiler] - flutter_typeahead 4.8.0 [flutter flutter_keyboard_visibility pointer_interceptor] - freezed_annotation 2.4.1 [collection json_annotation meta] - google_sign_in 6.1.5 [flutter google_sign_in_android google_sign_in_ios google_sign_in_platform_interface google_sign_in_web] - http 1.1.0 [async http_parser meta] - image_picker 1.0.4 [flutter image_picker_android image_picker_for_web image_picker_ios image_picker_linux image_picker_macos image_picker_platform_interface image_picker_windows] - intl 0.19.0 [clock meta path] - json_annotation 4.8.1 [meta] - loading_overlay 0.3.0 [flutter] - logger 2.0.2+1 - lottie 2.7.0 [archive flutter path vector_math] - map_location_picker 1.3.0-beta.1 [flutter google_maps_flutter google_maps_webapi geolocator http logger] - permission_handler 11.0.1 [flutter meta permission_handler_android permission_handler_apple permission_handler_windows permission_handler_platform_interface] - persistent_bottom_nav_bar 5.0.2 [flutter] - retrofit 4.0.3 [dio meta] - share_plus 7.2.1 [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 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] - shimmer 3.0.0 [flutter] - sign_in_with_apple 5.0.0 [flutter meta sign_in_with_apple_platform_interface sign_in_with_apple_web] - smooth_page_indicator 1.1.0 [flutter] - string_validator 1.0.2 - unorm_dart 0.3.0 - url_launcher 6.2.1 [flutter url_launcher_android url_launcher_ios url_launcher_linux url_launcher_macos url_launcher_platform_interface url_launcher_web url_launcher_windows] dev dependencies: - auto_route_generator 7.3.2 [build source_gen analyzer path build_runner code_builder dart_style xml args glob auto_route] - build_runner 2.4.6 [analyzer args async build build_config build_daemon build_resolvers build_runner_core code_builder collection crypto dart_style frontend_server_client glob graphs http_multi_server io js logging meta mime package_config path pool pub_semver pubspec_parse shelf shelf_web_socket stack_trace stream_transform timing watcher web_socket_channel yaml] - flutter_launcher_icons 0.13.1 [args checked_yaml cli_util image json_annotation path yaml] - flutter_native_splash 2.3.5 [args flutter flutter_web_plugins js html image meta path universal_io xml yaml] - 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] - freezed 2.4.5 [analyzer build build_config collection meta source_gen freezed_annotation json_annotation] - json_serializable 6.7.1 [analyzer async build build_config collection json_annotation meta path pub_semver pubspec_parse source_gen source_helper] - retrofit_generator 8.0.3 [analyzer build built_collection code_builder dart_style dio retrofit source_gen tuple protobuf] - very_good_analysis 5.1.0 transitive dependencies: - _fe_analyzer_shared 64.0.0 [meta] - _flutterfire_internals 1.3.34 [collection firebase_core firebase_core_platform_interface flutter meta] - analyzer 6.2.0 [_fe_analyzer_shared collection convert crypto glob meta package_config path pub_semver source_span watcher yaml] - archive 3.4.6 [crypto path pointycastle] - args 2.4.2 - async 2.11.0 [collection meta] - boolean_selector 2.1.1 [source_span string_scanner] - build 2.4.1 [analyzer async convert crypto glob logging meta package_config path] - build_config 1.1.1 [checked_yaml json_annotation path pubspec_parse yaml] - build_daemon 4.0.0 [built_collection built_value http_multi_server logging path pool shelf shelf_web_socket stream_transform watcher web_socket_channel] - build_resolvers 2.4.1 [analyzer async build collection convert crypto graphs logging package_config path pool pub_semver stream_transform yaml] - build_runner_core 7.2.11 [async build build_config build_resolvers collection convert crypto glob graphs json_annotation logging meta package_config path pool timing watcher yaml] - built_collection 5.1.1 - built_value 8.7.0 [built_collection collection fixnum meta] - characters 1.3.0 - checked_yaml 2.0.3 [json_annotation source_span yaml] - cli_util 0.4.0 [meta path] - clock 1.1.1 - code_builder 4.7.0 [built_collection built_value collection matcher meta] - collection 1.18.0 - connectivity_plus_platform_interface 1.2.4 [flutter meta plugin_platform_interface] - convert 3.1.1 [typed_data] - cross_file 0.3.3+6 [js meta] - crypto 3.0.3 [typed_data] - csslib 1.0.0 [source_span] - dart_style 2.3.3 [analyzer args path pub_semver source_span] - dbus 0.7.8 [args ffi meta xml] - facebook_auth_desktop 1.0.1 [flutter http flutter_secure_storage flutter_facebook_auth_platform_interface] - 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.1 [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 3.10.7 [_flutterfire_internals firebase_core flutter meta plugin_platform_interface] - firebase_analytics_web 0.5.7+6 [_flutterfire_internals firebase_analytics_platform_interface firebase_core firebase_core_web flutter flutter_web_plugins] - firebase_auth_platform_interface 7.2.7 [_flutterfire_internals collection firebase_core flutter meta plugin_platform_interface] - firebase_auth_web 5.11.6 [firebase_auth_platform_interface firebase_core firebase_core_web flutter flutter_web_plugins http_parser meta web] - firebase_core_platform_interface 5.0.0 [collection flutter flutter_test meta plugin_platform_interface] - firebase_core_web 2.17.0 [firebase_core_platform_interface flutter flutter_web_plugins meta web] - firebase_dynamic_links_platform_interface 0.2.6+34 [_flutterfire_internals firebase_core flutter meta plugin_platform_interface] - firebase_messaging_platform_interface 4.5.36 [_flutterfire_internals firebase_core flutter meta plugin_platform_interface] - firebase_messaging_web 3.8.6 [_flutterfire_internals firebase_core firebase_core_web firebase_messaging_platform_interface flutter flutter_web_plugins meta web] - fixnum 1.1.0 - flutter_facebook_auth_platform_interface 5.0.0 [flutter plugin_platform_interface] - flutter_facebook_auth_web 5.0.0 [flutter flutter_web_plugins js flutter_facebook_auth_platform_interface] - flutter_keyboard_visibility 5.4.1 [meta flutter_keyboard_visibility_platform_interface flutter_keyboard_visibility_linux flutter_keyboard_visibility_macos flutter_keyboard_visibility_web flutter_keyboard_visibility_windows flutter] - 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_local_notifications_linux 4.0.0+1 [dbus ffi flutter flutter_local_notifications_platform_interface path xdg_directories] - flutter_local_notifications_platform_interface 7.0.0+1 [flutter plugin_platform_interface] - flutter_localizations 0.0.0 [flutter intl characters clock collection material_color_utilities meta path vector_math] - flutter_plugin_android_lifecycle 2.0.17 [flutter] - flutter_secure_storage 9.0.0 [flutter flutter_secure_storage_linux flutter_secure_storage_macos flutter_secure_storage_platform_interface flutter_secure_storage_web flutter_secure_storage_windows meta] - flutter_secure_storage_linux 1.2.0 [flutter flutter_secure_storage_platform_interface] - flutter_secure_storage_macos 3.0.1 [flutter flutter_secure_storage_platform_interface] - flutter_secure_storage_platform_interface 1.0.2 [flutter plugin_platform_interface] - flutter_secure_storage_web 1.1.2 [flutter flutter_secure_storage_platform_interface flutter_web_plugins js] - flutter_secure_storage_windows 3.0.0 [ffi flutter flutter_secure_storage_platform_interface path path_provider win32] - flutter_web_plugins 0.0.0 [flutter characters collection material_color_utilities meta vector_math] - frontend_server_client 3.2.0 [async path] - geolocator 10.1.0 [flutter geolocator_platform_interface geolocator_android geolocator_apple geolocator_web geolocator_windows] - geolocator_android 4.4.0 [flutter geolocator_platform_interface uuid] - geolocator_apple 2.3.2 [flutter geolocator_platform_interface] - geolocator_platform_interface 4.2.0 [flutter plugin_platform_interface vector_math meta] - geolocator_web 2.2.0 [flutter flutter_web_plugins geolocator_platform_interface] - geolocator_windows 0.2.2 [flutter geolocator_platform_interface] - glob 2.1.2 [async collection file path string_scanner] - google_identity_services_web 0.2.2 [js meta] - google_maps 6.3.0 [js js_wrapping meta] - google_maps_flutter 2.5.0 [flutter google_maps_flutter_android google_maps_flutter_ios google_maps_flutter_platform_interface google_maps_flutter_web] - google_maps_flutter_android 2.5.3 [flutter flutter_plugin_android_lifecycle google_maps_flutter_platform_interface stream_transform] - google_maps_flutter_ios 2.3.2 [flutter google_maps_flutter_platform_interface stream_transform] - google_maps_flutter_platform_interface 2.4.1 [collection flutter plugin_platform_interface stream_transform] - google_maps_flutter_web 0.5.4+2 [collection flutter flutter_web_plugins google_maps google_maps_flutter_platform_interface sanitize_html stream_transform] - google_maps_webapi 0.0.22 [http meta json_annotation] - google_sign_in_android 6.1.20 [flutter google_sign_in_platform_interface] - google_sign_in_ios 5.6.3 [flutter google_sign_in_platform_interface] - google_sign_in_platform_interface 2.4.2 [flutter plugin_platform_interface quiver] - google_sign_in_web 0.12.0+5 [flutter flutter_web_plugins google_identity_services_web google_sign_in_platform_interface http js] - graphs 2.3.1 [collection] - html 0.15.4 [csslib source_span] - http_multi_server 3.2.1 [async] - http_parser 4.0.2 [collection source_span string_scanner typed_data] - image 4.1.3 [archive meta xml] - image_picker_android 0.8.8+2 [flutter flutter_plugin_android_lifecycle image_picker_platform_interface] - image_picker_for_web 3.0.1 [flutter flutter_web_plugins image_picker_platform_interface mime] - image_picker_ios 0.8.8+4 [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.1 [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] - io 1.0.4 [meta path string_scanner] - js 0.6.7 [meta] - js_wrapping 0.7.4 [js] - 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] - 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 - mime 1.0.4 - nm 0.5.0 [dbus] - package_config 2.1.0 [path] - path 1.9.0 - path_parsing 1.0.1 [vector_math meta] - path_provider 2.1.1 [flutter path_provider_android path_provider_foundation path_provider_linux path_provider_platform_interface path_provider_windows] - path_provider_android 2.2.1 [flutter path_provider_platform_interface] - path_provider_foundation 2.3.1 [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.1 [flutter platform plugin_platform_interface] - path_provider_windows 2.2.1 [ffi flutter path path_provider_platform_interface win32] - permission_handler_android 11.1.0 [flutter permission_handler_platform_interface] - permission_handler_apple 9.1.4 [flutter permission_handler_platform_interface] - permission_handler_platform_interface 3.12.0 [flutter meta plugin_platform_interface] - permission_handler_windows 0.1.3 [flutter permission_handler_platform_interface] - petitparser 5.4.0 [meta] - platform 3.1.3 - plugin_platform_interface 2.1.6 [meta] - pointer_interceptor 0.9.3+6 [flutter] - pointycastle 3.7.3 [collection convert js] - pool 1.5.1 [async stack_trace] - protobuf 3.1.0 [collection fixnum meta] - pub_semver 2.1.4 [collection meta] - pubspec_parse 1.2.3 [checked_yaml collection json_annotation pub_semver yaml] - quiver 3.2.1 [matcher] - riverpod 2.4.5 [meta stack_trace state_notifier] - sanitize_html 2.1.0 [html meta] - share_plus_platform_interface 3.3.1 [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.4 [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.1 [flutter plugin_platform_interface] - shared_preferences_web 2.2.1 [flutter flutter_web_plugins shared_preferences_platform_interface] - 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] - shelf_web_socket 1.0.4 [shelf stream_channel web_socket_channel] - sign_in_with_apple_platform_interface 1.0.0 [flutter plugin_platform_interface meta] - sign_in_with_apple_web 1.0.1 [flutter flutter_web_plugins sign_in_with_apple_platform_interface js] - sky_engine 0.0.99 - source_gen 1.4.0 [analyzer async build dart_style glob path source_span yaml] - source_helper 1.3.4 [analyzer collection source_gen] - source_span 1.10.0 [collection path term_glyph] - sprintf 7.0.0 - stack_trace 1.11.1 [path] - state_notifier 1.0.0 [meta] - stream_channel 2.1.2 [async] - stream_transform 2.1.0 - string_scanner 1.2.0 [source_span] - 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] - timezone 0.9.2 [path] - timing 1.0.1 [json_annotation] - tuple 2.0.2 - typed_data 1.3.2 [collection] - universal_io 2.2.2 [collection meta typed_data] - url_launcher_android 6.2.0 [flutter url_launcher_platform_interface] - url_launcher_ios 6.2.0 [flutter url_launcher_platform_interface] - url_launcher_linux 3.1.0 [flutter url_launcher_platform_interface] - url_launcher_macos 3.1.0 [flutter url_launcher_platform_interface] - url_launcher_platform_interface 2.2.0 [flutter plugin_platform_interface] - url_launcher_web 2.2.0 [flutter flutter_web_plugins url_launcher_platform_interface] - url_launcher_windows 3.1.0 [flutter url_launcher_platform_interface] - uuid 4.1.0 [crypto sprintf] - vector_graphics 1.1.9+1 [flutter vector_graphics_codec] - vector_graphics_codec 1.1.9+1 - vector_graphics_compiler 1.1.9+1 [args meta path_parsing xml vector_graphics_codec path] - vector_math 2.1.4 - vm_service 14.2.1 - watcher 1.1.0 [async path] - web 0.5.1 - web_socket_channel 2.4.0 [async crypto stream_channel] - win32 5.0.9 [ffi] - xdg_directories 1.0.3 [meta path] - xml 6.3.0 [collection meta petitparser] - yaml 3.1.2 [collection source_span string_scanner] ```

Additional context and comments

No response

TarekkMA commented 1 month ago

Hello @AsimBhadra Thank you for sharing this issue, I've tested the fluttterfire analytics example app on android and I didn't get any error in the logs. Would you mind sharing a reproduction project's code for this issue?

Also if you can upgrade flutter and test again that would be helpful

AsimBhadra commented 1 month ago

@TarekkMA In my case running the example project from flutterfire returns the same issue. Any idea why this issue pops up? I cannot find references to app-measurement.com anywhere.

TarekkMA commented 1 month ago

Can you try a VPN and see if that issue is resolved? I cannot produce it from my setup

TarekkMA commented 1 month ago

Also it might be worth checking on another phone.

AsimBhadra commented 1 month ago

Hi @TarekkMA,

I've been testing various solutions and it seems using a VPN resolves the issue. I'm located in Nepal, and without a VPN, I encounter the same error on both Wi-Fi and mobile data. However, the error code on mobile data is slightly different: javax.net.ssl.SSLHandshakeException.

Do you have any insights into why this might be happening?

TarekkMA commented 1 month ago

This seems to be a network related issue, nothing to be done from flutterfire side 🫤