4

I want to disable Crashlytics and Answers to be executed on Debugging environment.

I found many solutions on the web, but none describe how to disable the Answer module.

Right now, I´m using the following code. However, only Crashlytics is disabled.

CrashlyticsCore core = new CrashlyticsCore.Builder().disabled(BuildConfig.DEBUG).build();
Fabric.with(this, new Crashlytics.Builder().core(core).build(), new Answers());
Eugen Martynov
  • 19,888
  • 10
  • 61
  • 114
Oximer
  • 548
  • 5
  • 19
  • @marcin-orlowski this is not a duplicate of the referenced question. There are specific things to take into account with Fabric Answers. Please allow me to explain in an answer. – NoHarmDan Jun 03 '19 at 13:23

1 Answers1

0

How about:

CrashlyticsCore core = new CrashlyticsCore.Builder().disabled(BuildConfig.DEBUG).build();
Crashlytics crashlytics = new Crashlytics.Builder().core(core).build();
if (BuildConfig.DEBUG) {
    Fabric.with(this, crashlytics);
} else {
    Fabric.with(this, crashlytics, new Answers());
}
Eugen Martynov
  • 19,888
  • 10
  • 61
  • 114
  • My concern is what gonna happen to all Answer´s call spread all over the code. I don´t want to wrapper all of it. – Oximer Aug 14 '17 at 19:52
  • Sorry I didn't read the documentation first. So I would extract analytics interface and have two implementations for debug and release variants – Eugen Martynov Aug 14 '17 at 21:36
  • However, I still think that your user base will produce much more events to ignore small amount of events from development – Eugen Martynov Aug 14 '17 at 21:37
  • I'm not sure if you can in Answers ignore specific app versions (I might have version of your debug as prefixed with dev) or you can add suffixes for events if it is debug version – Eugen Martynov Aug 14 '17 at 21:38
  • 1
    This answer is technically correct, but there are things to be aware of: 1. Not initializing Answers is safe in regard to all the calls - they simply don't do anything. 2. But if you were to disable Answers in an app where they were previously enabled, they may still report events until the app is killed and restarted (which doesn't need to happen during an update, according to my tests). – NoHarmDan Jun 03 '19 at 13:27
  • @NoHarmDan it was the best guess since I don't use answers, please submit your answer that is more suitable for this question. – Eugen Martynov Jun 03 '19 at 14:07
  • I can't, since the question is marked as duplicate. – NoHarmDan Jun 04 '19 at 08:13