Provides a simple way for configuring your app crash handler.
Initialize the CrashHandler instance in your Application class, and provide a global configuration by defining CrashHandlerConfiguration object.
public class SampleApp extends Application {
@Override
public void onCreate() {
super.onCreate();
CrashHandlerConfiguration configuration = new CrashHandlerConfiguration.Builder(this).setLogLevel(LogLevel.FULL)
.setHomeActivity(MainActivity.class).build();
CrashHandler.getInstance().init(configuration);
}
}
All options in CrashHandlerConfiguration.Builder are optional. Use only those you really want to customize.
See all default values for config options here.
It does multiple things:
- initialize LeakCanary
- setup Timber with default Debug tree
- initialize Crashlytics
- connect your Timber exceptions to Crashlytics with CrashReportingTree
- setup uncaught exception handler
In order to use Crashlytics, you have to generate fabric.properties file in your module, and provide your apiKey and apiSecret. Remember to exclude this file from your repository.
Add following code snippet to your proguard configuration:
-keep class org.eclipse.mat.** { *; }
-keep class com.squareup.leakcanary.** { *; }