6

Everything works fine when I initialize my application with:

Fabric.with(this, new Crashlytics());

However, I get an exception when I use:

Fabric.with(this, new CrashlyticsCore());

The following exception:

FATAL EXCEPTION: main Process: com.weightbook, PID: 19438
java.lang.IllegalStateException: Crashlytics must be initialized by calling Fabric.with(Context) prior to calling Crashlytics.getInstance()
at com.crashlytics.android.Crashlytics.checkInitialized(Crashlytics.java:372)
at com.crashlytics.android.Crashlytics.setUserName(Crashlytics.java:248)
at com.weightbook.analytics.AnalyticsManager.setUsernameOnCrashlytics(AnalyticsManager.java:64)
Vadim Kotov
  • 8,084
  • 8
  • 48
  • 62
Kamilski81
  • 14,409
  • 33
  • 108
  • 161

1 Answers1

10

Mike from Fabric and Crashlytics here. Your first init call is correct, but you could also use:

Fabric.with(this, new CrashlyticsCore(), new Crashlytics());

or use:

Fabric.with(this, CrashlyticsCore.getInstance());

with the following imports:

import com.crashlytics.android.Crashlytics;
import com.crashlytics.android.core.CrashlyticsCore;
import io.fabric.sdk.android.Fabric;

Using just CrashlyticsCore.getInstance() will give you only Crashlytics crash reporting and nothing else, where as new Crashlytics() would include Beta and Answers.

Floern
  • 33,559
  • 24
  • 104
  • 119
Mike Bonnell
  • 16,181
  • 3
  • 61
  • 77
  • Thanks Miike! So it appears that to use Crashlytics you need....new Crashlytics() in there at least. Thanks!! How is CrashlyticsCore different then? – Kamilski81 Dec 17 '15 at 14:17
  • Ahh, I see what you're looking for. Clarified my answer. – Mike Bonnell Dec 17 '15 at 17:13
  • 1
    Hi Mike i have suggested an edit use new CrashlyticsCore() instead of CrashlyticsCore.getInstance() because getInstance() method is accessing Fabric singleton object before it's initialisation and crashing the app on launch – Bali Jul 24 '19 at 18:49