5

I am using just this in every Activity:

@Override
public void onStart() {
    super.onStart();
    EasyTracker.getInstance().activityStart(this);
}

@Override
public void onStop() {
    super.onStop();
    EasyTracker.getInstance().activityStop(this);
}

and going through this doc

I found out:

Using EasyTracker
To automatically track all uncaught exceptions in your app using EasyTracker, add this line to your analytics.xml file:

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

After tracking an exception using automatic exception tracking, EasyTracker will pass the exception on to the Thread's default exception handler.

When using automatic exception tracking, keep in mind the following:

  1. All exceptions tracked via automatic exception tracking are reported as fatal in Google Analytics.
  2. The description field is automatically populated using the stack trace.

But when i get an UncaughtException and the application crashes, in the Google Analytics description, it just shows:

An error occured while executing doInBackground()

not the Stack Trace as mentioned in the above points. Any thing needs to be added??

Thank You

Miral Dhokiya
  • 1,720
  • 13
  • 26
Archie.bpgc
  • 23,812
  • 38
  • 150
  • 226
  • This is the best solution I found so far: http://stackoverflow.com/questions/14009883/exception-stack-trace-lost-in-google-analytics-v2-for-android – tofi9 Jan 23 '13 at 16:23
  • Upvoting this, I am facing the same issue. I don't understand why Easytracker shows only the last line of the stack trace... – Radu Apr 25 '13 at 12:45
  • Exact same situation here. Did you ever find a solution? – theblang Feb 18 '14 at 14:51
  • @mattblang I am using [ACRA](http://acra.ch/) – Archie.bpgc Feb 19 '14 at 03:49
  • I use a solution called AppBugTracker is more or less like Acra but without the overhead to create your site to collect information and have some helper class to not only capture the uncaucht exception but olso the exception more relevant for you. Have also graphics report and email reports. – frusso Feb 26 '14 at 17:48

2 Answers2

4

I use an open source tool called ACRA for uncaught exception reporting. It provides significantly more information than Google Analytics or Flurry do, and submits reports to a Google Doc, to which you can get email notification for every report added.

I use Google Analytics for the rest.

Amir Uval
  • 14,425
  • 4
  • 50
  • 74
  • Do you use something like Bugsense with ACRA? I use ACRA also but is not good to see errors in the spreadsheet – Gabriel Augusto Feb 05 '14 at 19:11
  • For each release I've backed up the proguard dump files, and wrote a small script to retrace the stack trace against the correct dump. I've migrated to Crashlytics later. It has a capture ability like ACRA, and does the retracing automatically. – Amir Uval Feb 05 '14 at 21:40
3

You should use a custom exception parser to get the whole stacktrace

import org.apache.commons.lang3.exception.ExceptionUtils;
import com.google.analytics.tracking.android.ExceptionParser;

public class AnalyticsExceptionParser implements ExceptionParser {

public String getDescription(String p_thread, Throwable p_throwable) {
    return "Thread: " + p_thread + ", Exception: " +     ExceptionUtils.getStackTrace(p_throwable);
}
}

and set this as default in you activity, like

public void setupGoogleAnalyticsCrashReportParser() {

    EasyTracker.getInstance().setContext(this);

    Thread.UncaughtExceptionHandler uncaughtExceptionHandler = Thread.getDefaultUncaughtExceptionHandler();
    if (uncaughtExceptionHandler instanceof ExceptionReporter) {
        ExceptionReporter exceptionReporter = (ExceptionReporter) uncaughtExceptionHandler;
        exceptionReporter.setExceptionParser(new AnalyticsExceptionParser());
    }
}

Hope this helps to someone.

Analizer
  • 1,594
  • 16
  • 30