6

I have decided to include the Firebase Crash API 9.0.1 into my Android app. At the moment everything is working fine. Now I want to give my users the opportunity to disable, that Firebase is sending the Crash reports automatically.

Firebase Analytics can be disabled with this code snippet

FirebaseAnalytics.getInstance(this).setAnalyticsCollectionEnabled(false);

Does anyone of you know a similar way to disable crash reporting?

Many thanks

Doug Stevenson
  • 297,357
  • 32
  • 422
  • 441
Mojo
  • 377
  • 6
  • 18
  • Possible duplicate of [How to disable Firebase Crash Reporting when the app is running on debug?](http://stackoverflow.com/questions/37396826/how-to-disable-firebase-crash-reporting-when-the-app-is-running-on-debug) – Doug Stevenson Jun 03 '16 at 19:36
  • Any luck on finding a way to disable crash reporting? – Alin Jul 14 '16 at 09:20
  • See below answer of mine for similar question: http://stackoverflow.com/a/41712248/5745574 – Vipul Kumar Jan 18 '17 at 06:03

3 Answers3

5

Sorry for short answer but currently there is no official support for this.

EDIT: 30/10/2017

Now it is possible to enable/disable at build time adding in the AndroidManifest.xml:

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

or runtime using:

FirebaseCrash.enableCrash(true|false);

More info here.

Gabriele Mariotti
  • 320,139
  • 94
  • 887
  • 841
  • I can't believe this isn't available. I mean I'm going nuts looking at crashes caused by developers and not users. :/ Android is easy to simply remove the library... Maybe iOS has a way to not compile this? – Jona Mar 16 '17 at 21:14
1

Yes it is possible now. Check this, Disable Crash Reporting

Simply add the below line to your code in the first activity or even better in the Application class.

FirebaseCrash.setCrashCollectionEnabled(false);

To enable,

FirebaseCrash.setCrashCollectionEnabled(true);

This is really helpful when we have multiple build types such as Debug, Release etc.

Andro Selva
  • 53,910
  • 52
  • 193
  • 240
-2

You can find the instructions on the page: https://firebase.google.com/support/guides/disable-analytics

Disable Analytics collection on Android

Temporarily disable collection

If you wish to temporarily disable Analytics collection, such as to get end-user consent before collecting data, you can set the value of firebase_analytics_collection_enabled to false in your app's AndroidManifest.xml in the application tag. For example:

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

To re-enable collection, such as after an end-user provides consent, call the setAnalyticsCollectionEnabled() method of the FirebaseAnalytics class. For example:

setAnalyticsCollectionEnabled(true);

If you need to suspend collection again for any reason, you can call

setAnalyticsCollectionEnabled(false);

and collection is suspended until you re-enable it.

Permanently deactivate collection

If you need to deactivate Analytics collection permanently in a version of your app, set firebase_analytics_collection_deactivated to true in your app's AndroidManifest.xml in the application tag. For example:

<meta-data android:name="firebase_analytics_collection_deactivated" android:value="true" />
Alécio Carvalho
  • 13,481
  • 5
  • 68
  • 74