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.71k stars 3.97k forks source link

pluginConstants['isCrashlyticsCollectionEnabled'] != null is not true #4631

Closed remymumoh closed 3 years ago

remymumoh commented 3 years ago

Bug report

Describe the bug whenever I try to run flutter web I get this error pluginConstants['isCrashlyticsCollectionEnabled'] != null is not true

Steps to reproduce

Steps to reproduce the behavior:

  1. Go to main.dart add the code

    void main() async {
    WidgetsFlutterBinding.ensureInitialized();
    await Firebase.initializeApp();
    FirebaseCrashlytics.instance.setCrashlyticsCollectionEnabled(true);
    FlutterError.onError = FirebaseCrashlytics.instance.recordFlutterError;
    
    Isolate.current.addErrorListener(RawReceivePort((pair) async {
    final List<dynamic> errorAndStacktrace = pair;
    await FirebaseCrashlytics.instance.recordError(
      errorAndStacktrace.first,
      errorAndStacktrace.last,
    );
    }).sendPort);
    
    if (kDebugMode) {
    // Force disable Crashlytics collection while doing every day development.
    // Temporarily toggle this to true if you want to test crash reporting in your app.
    await FirebaseCrashlytics.instance.setCrashlyticsCollectionEnabled(false);
    } else {
    // Handle Crashlytics enabled status when not in Debug,
    // e.g. allow your users to opt-in to crash reporting.
    }
    initializeDateFormatting().then((_) => runApp(MyApp()));
    }
  2. in index.html add

    <body>
    <script src="https://www.gstatic.com/firebasejs/7.20.0/firebase-app.js"></script>
    <!-- Firebase Configuration -->
    <script>
      var firebaseConfig = {
        apiKey: "...",
        authDomain: "[YOUR_PROJECT].firebaseapp.com",
        databaseURL: "https://[YOUR_PROJECT].firebaseio.com",
        projectId: "[YOUR_PROJECT]",
        storageBucket: "[YOUR_PROJECT].appspot.com",
        messagingSenderId: "...",
        appId: "1:...:web:...",
        measurementId: "G-...",
      };
    
      // Initialize Firebase
      firebase.initializeApp(firebaseConfig);
    </script>
    
    <script src="main.dart.js" type="application/javascript"></script>
    </body>
    </html>
  3. See error or incorrect behavior

pluginConstants['isCrashlyticsCollectionEnabled'] != null
is not true

A clear and concise description of what you expected to happen.

web app to start as crashlytics doesnt support flutter web

Additional context

Add any other context about the problem here.


Flutter doctor

Run flutter doctor and paste the output below: Doctor summary (to see all details, run flutter doctor -v): [√] Flutter (Channel beta, 1.25.0-8.1.pre, on Microsoft Windows [Version 10.0.19042.685], locale en-US) [√] Chrome - develop for the web [√] Android Studio (version 4.1.0) [√] IntelliJ IDEA Ultimate Edition (version 2020.3) [√] VS Code (version 1.52.1) [√] Connected device (2 available)

! Doctor found no issues.

Click To Expand ``` PASTE OUTPUT INSIDE HERE ```

Flutter dependencies

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

Dart SDK 2.12.0-133.2.beta Flutter SDK 1.25.0-8.1.pre clt_survey 1.0.10+19 dependencies: - barcode_scan 2.0.2 [flutter] - build_runner 1.10.12 [args async build build_config build_daemon build_resolvers build_runner_core code_builder collection crypto dart_style glob graphs http_multi_server io js logging meta mime path pedantic pool pub_semver pubspec_parse shelf shelf_web_socket stack_trace stream_transform timing watcher web_socket_channel yaml] - connectivity 0.4.9+5 [flutter meta connectivity_platform_interface connectivity_macos connectivity_for_web] - cupertino_icons 0.1.3 - device_info 0.4.2+10 [flutter device_info_platform_interface] - dio 3.0.9 [http_parser path] - dropdown_formfield 0.1.3 [flutter] - flutter 0.0.0 [characters collection meta typed_data vector_math sky_engine] - flutter_beep 0.2.0 [flutter] - flutter_offline 0.3.0 [flutter connectivity] - flutter_svg 0.19.1 [flutter meta path_drawing vector_math xml] - font_awesome_flutter 8.11.0 [flutter] - geolocator 6.1.13 [flutter geolocator_platform_interface] - http 0.12.2 [http_parser path pedantic] - image_downloader 0.19.2 [flutter] - image_picker 0.6.7+20 [flutter flutter_plugin_android_lifecycle image_picker_platform_interface] - intl 0.16.1 [path] - json_to_form 0.0.4 [flutter] - location 3.2.1 [flutter location_platform_interface location_web meta] - moor_flutter 3.1.0 [moor sqflite meta path flutter] - moor_generator 3.4.0 [collection recase meta path json_annotation stream_transform args logging cli_util moor sqlparser analyzer analyzer_plugin_fork source_span build build_resolvers build_config dart_style source_gen] - package_info 0.4.3+2 [flutter] - path 1.8.0-nullsafety.3 - progress_dialog 1.2.4 [flutter] - qr_code_scanner 0.2.1 [flutter] - qr_flutter 3.2.0 [flutter qr] - responsive_builder 0.2.0+2 [flutter] - shared_preferences 0.5.12+4 [meta flutter shared_preferences_platform_interface shared_preferences_linux shared_preferences_macos shared_preferences_web shared_preferences_windows] - splashscreen 1.3.5 [flutter] - table_calendar 2.3.3 [flutter intl simple_gesture_detector] - uuid 2.2.2 [crypto convert] dev dependencies: - firebase_core 0.5.3 [firebase_core_platform_interface flutter quiver meta firebase_core_web] - firebase_crashlytics 0.2.4 [flutter stack_trace firebase_core firebase_core_platform_interface firebase_crashlytics_platform_interface] - flutter_launcher_icons 0.8.1 [image args yaml path] - flutter_test 0.0.0 [flutter test_api path fake_async clock stack_trace vector_math async boolean_selector characters charcode collection matcher meta source_span stream_channel string_scanner term_glyph typed _data] transitive dependencies: - _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] - analyzer_plugin_fork 0.3.0 [analyzer charcode dart_style pub_semver] - archive 2.0.13 [crypto args path] - args 1.6.0 - async 2.5.0-nullsafety.3 [collection] - boolean_selector 2.1.0-nullsafety.3 [source_span string_scanner] - build 1.6.1 [analyzer async convert crypto glob logging meta path] - build_config 0.4.5 [checked_yaml json_annotation meta path pubspec_parse yaml] - build_daemon 2.1.5 [built_collection built_value http_multi_server logging pedantic path pool shelf shelf_web_socket stream_transform watcher web_socket_channel] - build_resolvers 1.5.2 [analyzer build crypto graphs logging meta path package_config pool pub_semver] - build_runner_core 6.1.6 [async build build_config build_resolvers collection convert crypto glob graphs logging meta path package_config pedantic pool timing watcher yaml] - built_collection 4.3.2 [collection quiver] - built_value 7.1.0 [built_collection collection fixnum quiver] - characters 1.1.0-nullsafety.5 - charcode 1.2.0-nullsafety.3 - checked_yaml 1.0.4 [json_annotation source_span yaml] - cli_util 0.1.4 [path] - clock 1.1.0-nullsafety.3 - code_builder 3.5.0 [built_collection built_value collection matcher meta] - collection 1.15.0-nullsafety.5 - connectivity_for_web 0.3.1+4 [connectivity_platform_interface flutter_web_plugins flutter] - connectivity_macos 0.1.0+7 [flutter] - connectivity_platform_interface 1.0.6 [flutter meta plugin_platform_interface] - convert 2.1.1 [charcode typed_data] - crypto 2.1.5 [collection convert typed_data] - dart_style 1.3.10 [analyzer args path source_span] - device_info_platform_interface 1.0.1 [flutter meta plugin_platform_interface] - fake_async 1.2.0-nullsafety.3 [clock collection] - ffi 0.1.3 - file 5.2.1 [intl meta path] - firebase_core_platform_interface 2.1.0 [flutter meta plugin_platform_interface quiver] - firebase_core_web 0.2.1+1 [firebase_core_platform_interface flutter flutter_web_plugins meta js] - firebase_crashlytics_platform_interface 1.1.4 [flutter meta collection firebase_core plugin_platform_interface] - fixnum 0.10.11 - flutter_plugin_android_lifecycle 1.0.11 [flutter] - flutter_web_plugins 0.0.0 [flutter js characters collection meta typed_data vector_math] - geolocator_platform_interface 1.0.8 [flutter meta plugin_platform_interface vector_math] - glob 1.2.0 [async collection node_io path pedantic string_scanner] - graphs 0.2.0 - http_multi_server 2.2.0 [async] - http_parser 3.1.4 [charcode collection source_span string_scanner typed_data] - image 2.1.19 [archive xml meta] - image_picker_platform_interface 1.1.1 [flutter meta http plugin_platform_interface] - io 0.3.4 [charcode meta path string_scanner] - js 0.6.3-nullsafety.3 - json_annotation 3.1.1 - location_platform_interface 1.1.0 [flutter meta plugin_platform_interface] - location_web 1.0.1 [flutter flutter_web_plugins http_parser js location_platform_interface meta] - logging 0.11.4 - matcher 0.12.10-nullsafety.3 [stack_trace] - meta 1.3.0-nullsafety.6 - mime 0.9.7 - moor 3.4.0 [meta convert collection synchronized pedantic sqlite3] - node_interop 1.2.1 [js] - node_io 1.2.0 [file node_interop path] - package_config 1.9.3 [path charcode] - path_drawing 0.4.1+1 [vector_math meta path_parsing flutter] - path_parsing 0.1.4 [vector_math meta] - path_provider_linux 0.0.1+2 [path xdg_directories path_provider_platform_interface flutter] - path_provider_platform_interface 1.0.4 [flutter meta platform plugin_platform_interface] - path_provider_windows 0.0.4+3 [path_provider_platform_interface meta path flutter ffi win32] - pedantic 1.9.2 [meta] - petitparser 3.1.0 [meta] - platform 2.2.1 - plugin_platform_interface 1.0.3 [meta] - pool 1.4.0 [async stack_trace] - process 3.0.13 [file intl meta path platform] - pub_semver 1.4.4 [collection] - pubspec_parse 0.1.7 [checked_yaml json_annotation pub_semver yaml] - qr 1.3.0 [meta] - quiver 2.1.5 [matcher meta] - recase 3.0.1 - shared_preferences_linux 0.0.2+4 [file flutter meta path path_provider_linux shared_preferences_platform_interface] - shared_preferences_macos 0.0.1+11 [shared_preferences_platform_interface flutter] - shared_preferences_platform_interface 1.0.4 [meta flutter] - shared_preferences_web 0.1.2+7 [shared_preferences_platform_interface flutter flutter_web_plugins meta] - shared_preferences_windows 0.0.1+3 [shared_preferences_platform_interface flutter ffi file meta path path_provider_platform_interface path_provider_windows] - shelf 0.7.9 [async collection http_parser path stack_trace stream_channel] - shelf_web_socket 0.2.3 [shelf web_socket_channel stream_channel] - simple_gesture_detector 0.1.6 [flutter] - sky_engine 0.0.99 - source_gen 0.9.10+1 [analyzer async build dart_style glob meta path pedantic source_span] - source_span 1.8.0-nullsafety.4 [charcode collection path term_glyph] - sqflite 1.3.1+2 [flutter sqflite_common path] - sqflite_common 1.0.2+1 [synchronized path meta] - sqlite3 0.1.8 [collection ffi meta] - sqlparser 0.11.0 [meta collection source_span charcode] - stack_trace 1.10.0-nullsafety.6 [path] - stream_channel 2.1.0-nullsafety.3 [async] - stream_transform 1.2.0 - string_scanner 1.1.0-nullsafety.3 [charcode source_span] - synchronized 2.2.0+2 - term_glyph 1.2.0-nullsafety.3 - test_api 0.2.19-nullsafety.6 [async boolean_selector collection meta path source_span stack_trace stream_channel string_scanner term_glyph matcher] - timing 0.1.1+3 [json_annotation] - typed_data 1.3.0-nullsafety.5 [collection] - vector_math 2.1.0-nullsafety.5 - watcher 0.9.7+15 [async path pedantic] - web_socket_channel 1.1.0 [async crypto stream_channel] - win32 1.7.4 [ffi] - xdg_directories 0.1.2 [meta path process] - xml 4.5.1 [collection convert meta petitparser] - yaml 2.2.1 [charcode collection string_scanner source_span] ``` PASTE OUTPUT INSIDE HERE ```

markusaksli-nc commented 3 years ago

Hi @remymumoh firebase_crashlytics isn't supported on web yet. You can check the platform support status of the FlutterFire packages at https://firebase.flutter.dev/ or https://github.com/FirebaseExtended/flutterfire. Closing since the plugin isn't supposed to work on web. If you disagree please let me know. Thank you

remymumoh commented 3 years ago

Hi Mark, incase I dont want to use it for web, am aware web is not supported, but when I shift to web, I have to comment out the crash analytics on main.dart for the web to work, thats my issue disabling when I want to run web and enabling when I want to use mobile

markusaksli-nc commented 3 years ago

Can you not use kIsWeb in a conditional for this?