firebase_crashlytics_collection_enabled not working in new Firebase Crashlytics SDK

Viewed 3323

I've trying to use the new Firebase Crashlytics SDK after Fabric will close on 31st March which is currently in beta.

I'll try to ensure that crash logs will only be transmitted when I have consent from the user. In the documentation they mention the following:

By default, Crashlytics automatically collects crash reports for all your app's users. To give users more control over the data they send, you can enable opt-in reporting for your users by disabling automatic collection and initializing Crashlytics only for selected users:

  1. Turn off automatic collection with a meta-data tag in your AndroidManifest.xml file:

    <meta-data android:name="firebase_crashlytics_collection_enabled" android:value="false" />

Unfortunately that won't work in my app. After I let the app crash intentionally, the crash still will be automatically transmitted.

How can I assure that crashes won't be automatically transmitted?

3 Answers

If you call sendUnsentReports(), that will override the setCrashlyticsCollectionEnabled setting. Also, it is necessary to restart the app before a change in automatic collection will be respected.

If a user has opt-in reporting disabled, incurs an error, and then later enables reporting, any unsent reports previously accumulated will then all get sent when opt-in gets enabled, so it's also necessary to deleteUnsentReports() before enabling opt-in reporting.

It was a probalby a bug. After upgrading to

implementation("com.google.firebase:firebase-crashlytics:17.4.0")

It will work as expected. No need for a restart of the app.

Seems like the call to setCrashlyticsCollectionEnabled is sticky. So if you set it once in your app's lifetime, whatever is in your AndroidManifest.xml will be ignored on consecutive runs of the app. That's what happened to me and made me wonder if the meta-data setting in my manifest is being ignored.
You can clear this by either calling `setCrashlyticsCollectionEnabled(null), or by reinstalling the app.

Related