UPDATE
Please see @kmityak answer as Crashlytics/Fabric initialization is now asynchronous and my solution below is no longer valid.
ORIGINAL ANSWER
You can set your custom UncaughtExceptionHandler providing that it will pass exception to default UncaughtExceptionHandler to be handled later via Crashlytics.
Below code is implemented inside Application subclass:
private static Thread.UncaughtExceptionHandler mDefaultUEH;
private static Thread.UncaughtExceptionHandler mCaughtExceptionHandler = new Thread.UncaughtExceptionHandler() {
@Override
public void uncaughtException(Thread thread, Throwable ex) {
// Custom logic goes here
// This will make Crashlytics do its job
mDefaultUEH.uncaughtException(thread, ex);
}
};
@Override
public void onCreate() {
super.onCreate();
// Order is important!
// First, start Crashlytics
Crashlytics.start(this);
// Second, set custom UncaughtExceptionHandler
mDefaultUEH = Thread.getDefaultUncaughtExceptionHandler();
Thread.setDefaultUncaughtExceptionHandler(mCaughtExceptionHandler);
}
Second option is to register Crashlytics after setting your custom UncaughtExceptionHandler – then all uncaught exceptions will be reported by Crashlytics as fatals, and after that passed to your custom handler.