Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Android / Timber / Crashlytics tree to send logs in production
public class SkempiApp extends Application {
public void onCreate() {
if (BuildConfig.DEBUG) {
Timber.plant(new Timber.DebugTree());
} else {
Timber.plant(new CrashlyticsTree(this, new DeviceInfo(this)));
public class CrashlyticsTree extends Timber.Tree {
public CrashlyticsTree(Context context, DeviceInfo deviceInfo) {
Fabric.with(context, new Crashlytics());
// Put some debug variables for every crash
// CrashlyticsCore core = Crashlytics.getInstance().core;
// core.setString("Git SHA", BuildConfig.GIT_SHA);
protected void log(int priority, String tag, String message, Throwable t) {
if (priority == Log.VERBOSE && !"release".equals(BuildConfig.BUILD_TYPE)) {
//Dont log verbose messages and avoid not release builds to send crash to crashlytics
CrashlyticsCore core = Crashlytics.getInstance().core;
core.log(Log.ERROR, tag, message);
if (t != null && priority == Log.ERROR) {
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment