谷歌分析崩溃报告只显示堆栈跟踪的第一行 [英] google analytics crash report only shows first line of stacktrace

查看:29
本文介绍了谷歌分析崩溃报告只显示堆栈跟踪的第一行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的应用程序使用 Google Analytics 来跟踪异常和崩溃(以及其他问题).我使用这个函数来获取堆栈跟踪:

My application uses Google Analytics to track exceptions and crashes (among other thigs). I use this function to get the stacktrace:

public static void sendErrorReportViaGoogleAnalytics(Exception e) {

    e.printStackTrace();
    Tracker myTracker = EasyTracker.getTracker();
    myTracker.sendException(getDescription(e), false);
}

public static String getDescription(Exception t) {

    final StringBuilder result = new StringBuilder();
    result.append(t.toString());
    result.append(',');
    String oneElement;

    for (StackTraceElement element : t.getStackTrace()) {
        oneElement = element.toString();
        result.append(oneElement);
        result.append(",");
    }

    return result.toString();
}

这很好用,在谈论异常时,我只是在异常处理代码的 catch 部分调用 sendErrorReportViaGoogleAnalytics(),但是当涉及到崩溃时,我只得到一行堆栈跟踪,例如

This works fine, when talking about exceptions, I just call sendErrorReportViaGoogleAnalytics() in the catch part of my exception handling codes, but when it comes to crashes, I only get one line of the stacktrace, like

Binary XML file line #11: Error inflating class fragment

我设置了

<bool name="ga_reportUncaughtExceptions">true</bool>

在 analytics.xml 中,因为我使用的是 EasyTracker.

in analytics.xml, as I'm using EasyTracker.

如果发生崩溃,我应该怎么做才能获得完整的堆栈跟踪?

What should I do to get the full stacktrace in case of crashes as well?

推荐答案

因为你没有描述你实际做了什么来捕捉崩溃,所以我只能把你送到文档:https://developers.google.com/analytics/devguides/collection/android/v2/异常

Since you didn't describe what you actually did in order to catch the crashes then I can only send you to the docs: https://developers.google.com/analytics/devguides/collection/android/v2/exceptions

如果您使用的是 EasyTracker,您可以声明:

If you are using EasyTracker you can declare:

<bool name="ga_reportUncaughtExceptions">true</bool>

否则,您可以按照描述实现 ExceptionReporter 类并将其附加到您的线程.

otherwise you can implement the ExceptionReporter class as described and attach it to your thread.

这篇关于谷歌分析崩溃报告只显示堆栈跟踪的第一行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆