问题描述
我的应用程序使用谷歌Analytics(分析)来跟踪异常和崩溃(其它thigs之间)。我用这个函数来获取堆栈跟踪:
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();
}
这工作得很好,当谈到例外,我只需要调用sendErrorReportViaGoogleAnalytics()在我的异常处理codeS的渔获组成部分,但是当涉及到崩溃,我只得到一条线的堆栈跟踪,如
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?
推荐答案
既然你没有说明你居然为了赶在崩溃那我只能送你到文档做了什么:的
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.
这篇关于谷歌分析崩溃报告只能显示堆栈跟踪的第一行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!