Android - how to send crash reports?

2019-03-08 21:24发布

It seems that as of Android 2.2, there is a new feature for sending crash reports, as mentioned in the links:

How do I use this feature? Is it automatic for each application downloaded from the market (aka Google Play Store)? Where can I find more info about this feature?

Also, is it possible to customize what is being sent, perhaps by using DefaultExceptionHandler, and put our own description of the crash?

NOTE: i know that there are plenty of tools for sending crash reports (like ACRA) , but i wish to check first if it's possible to use what's already given.

EDIT: I've succeeded modifying the exception that is passed further, hoping that this will also change the report that is sent to the developer website of Google.

Here's a sample code that is relevant for this:

private static class DefaultExceptionHandler implements java.lang.Thread.UncaughtExceptionHandler
...
@Override
public void uncaughtException(Thread t, Throwable e)
{
  final StackTraceElement[] exceptionStackTrace = e.getStackTrace();
  Exception exception = new Exception("my new exception!", e);
  final StackTraceElement[] newExceptionStackTrace = new StackTraceElement[exceptionStackTrace.length + 1];
  System.arraycopy(exceptionStackTrace, 0, newExceptionStackTrace, 1, exceptionStackTrace.length);
  newExceptionStackTrace[0] = new StackTraceElement("TEST CLASS", "TEST METHOD", "TEST FILE", 0);
  exception.setStackTrace(newExceptionStackTrace);
_defaultUEH.uncaughtException(t, exception); //this will hopefully call the default handling of the exception for reporting
}

1条回答
我欲成王,谁敢阻挡
2楼-- · 2019-03-08 22:10

What you have described sounds like the build in feature, and as far as I know, you cannot customize this. The data will be send to the googlePlay dev account which uploaded the app. I have seen customizations made by Sense, or Custom Roms. The only way to get your own Logs, is to use the DefaultErrorHandler you mentioned. As a good practice I would check, if you can catch the error yourself, (maybe log it somewhere). If not I would rethrow this error, to give the user a chance to give you hints , what he has done

查看更多
登录 后发表回答