使用 Timber 和自定义报告树无法看到 Fabric 中的实际崩溃

Can´t see the actual crash in Fabric using Timber and a custom Reporting Tree

我的树:

private static class CrashlyticsReportingTree extends Timber.HollowTree {

    public CrashlyticsReportingTree(Context context) {
      Fabric.with(context, new Crashlytics());
    }

    private static String maybeFormat(String message, Object... args) {
      // If no varargs are supplied, treat it as a request to log the string without formatting.
      if (args == null || args.length == 0) {
        return message;
      } else {
        return String.format(message, args);
      }
    }

    @Override
    public void e(String message, Object... args) {
      String completeMessage = maybeFormat(message, args);
      Crashlytics.logException(new Throwable(completeMessage));
    }

    @Override
    public void e(Throwable t, String message, Object... args) {
      String completeMessage = maybeFormat(message, args);
      Crashlytics.log(completeMessage);
      Crashlytics.logException(t);
    }

  }

错误报告中 Fabric 的第一行是

...App$CrashlyticsReportingTree.e (App.java:73)
timber.log.Timber.e (Timber.java:183)
timber.log.Timber.e (Timber.java:54)

为什么? 如何从堆栈树中删除这些行?

我使用以下 Timber 树向 Crashlytics 报告。 不确定为什么你的在日志中显示 timber.log.Timber.e,而我的没有。 也许是因为你在 log 方法中创建了一个新的 Throwable?

   private static class CrashReportingTree extends Timber.HollowTree {
        @Override public void e(Throwable t, String message, Object... args) {
            if(crashlyticsEnabled) {
                Crashlytics.logException(t);
            }
        }

        @Override public void e(String message, Object... args) {
            if(crashlyticsEnabled) {
                final String formattedMessage = String.format(message, args);
                final String tag = "";
                Crashlytics.log(Log.ERROR, tag, formattedMessage);
            }
        }
    }