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.61k stars 3.95k forks source link

[firebase_crashlytics]: firebase_crashlytics_collection_enabled setting in AndroidManifest.xml is being ignored #13105

Closed zjcz closed 2 weeks ago

zjcz commented 1 month ago

Is there an existing issue for this?

Which plugins are affected?

Crashlytics

Which platforms are affected?

Android

Description

I want to be able to provide my users with the ability to opt-in to Crashlytics. Error reporting will be disabled by default and it will be turned on in code using FirebaseCrashlytics.instance.setCrashlyticsCollectionEnabled(true) if the user has opted-in.

I have followed the guide Enable opt-in reporting to disable Crashlytics and added the config to my ~/android/app/src/main/AndroidManifest.xml file but crash reports are still being sent regardless. If I run the code FirebaseCrashlytics.instance.setCrashlyticsCollectionEnabled(false) then crash reports are not sent, so I think the problem is with the plugin reading the setting from AndroidManifest.xml

This was working on May 22 2024 when I first added the feature to my app but has recently stopped working. I have created a new test app with just this functionality in to ensure no other plugins are interfering - firebase_sample.

Reproducing the issue

Firebase Core version

3.2.0

Flutter Version

3.22.3

Relevant Log Output

No response

Flutter dependencies

Expand Flutter dependencies snippet
```yaml flutter pub deps -- --style=compact Dart SDK 3.4.4 Flutter SDK 3.22.3 firebase_sample 1.0.0+1 dependencies: - firebase_analytics 11.2.0 [firebase_analytics_platform_interface firebase_analytics_web firebase_core firebase_core_platform_interface flutter] - firebase_core 3.2.0 [firebase_core_platform_interface firebase_core_web flutter meta] - firebase_crashlytics 4.0.3 [firebase_core firebase_core_platform_interface firebase_crashlytics_platform_interface flutter stack_trace] - flutter 0.0.0 [characters collection material_color_utilities meta vector_math sky_engine] dev dependencies: - flutter_lints 3.0.2 [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.39 [collection firebase_core firebase_core_platform_interface flutter meta] - async 2.11.0 [collection meta] - boolean_selector 2.1.1 [source_span string_scanner] - characters 1.3.0 - clock 1.1.1 - collection 1.18.0 - fake_async 1.3.1 [clock collection] - firebase_analytics_platform_interface 4.2.0 [_flutterfire_internals firebase_core flutter meta plugin_platform_interface] - firebase_analytics_web 0.5.9 [_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.3 [firebase_core_platform_interface flutter flutter_web_plugins meta web] - firebase_crashlytics_platform_interface 3.6.39 [_flutterfire_internals collection firebase_core flutter meta plugin_platform_interface] - flutter_web_plugins 0.0.0 [flutter characters collection material_color_utilities meta vector_math] - 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 3.0.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 - path 1.9.0 - plugin_platform_interface 2.1.8 [meta] - sky_engine 0.0.99 - source_span 1.10.0 [collection path term_glyph] - stack_trace 1.11.1 [path] - stream_channel 2.1.2 [async] - 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] - vector_math 2.1.4 - vm_service 14.2.1 - web 0.5.1 ```

Additional context and comments

I have read previous issue [firebase_crashlytics] enable opt_in reporting not working correctly #6934 however I cannot find any resolution to this on the Android SDK repository, or any other similar recent issues. Also, as I am relatively new to Flutter there is a chance this is a user issue.

Lyokone commented 1 month ago

Thanks for the report, I can reproduce. I wonder if something has changed either on the Android SDK or Flutter build process so it doesn't get picked out. Which version of Flutter were you using in May?

zjcz commented 1 month ago

I was using 3.22.0. I only upgraded to 3.22.3 on Friday (26 July 2024) to see if it fixed the issue.

I was also using the following versions of the firebase plugins and again I only upgraded to the latest hoping to fix the issue: firebase_core: 2.31.0 firebase_crashlytics: 3.5.5 firebase_analytics: 10.10.5

zjcz commented 1 month ago

I have created a new Java Android app and I cannot recreate the issue there. I have created a new app in Android Studio, then followed the documentation to setup Firebase in the app. The app behaves as expected (with the firebase_crashlytics_collection_enabled set to false in AndroidManifest.xml no crash reports are sent. Setting to true in AndroidManifest.xml sends the reports.)

The example I have created uses the gradle plugin id("com.google.firebase.crashlytics") version "3.0.2" apply false which is pulling in the dependency com.google.firebase:firebase-crashlytics:19.0.3.

If there is anything else I can do to help diagnose please let me know.