15

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
}
android developer
  • 114,585
  • 152
  • 739
  • 1,270

1 Answers1

5

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

Rafael T
  • 15,401
  • 15
  • 83
  • 144
  • yes , i suspected that it's built in and that there is no API . however , is it possible to use the DefaultExceptionHandler in order to add more information of my own to the report? if so , how ? i know i've succeeded catching the exceptions , but what should i do in order to pass more info further to the built in feature of crash report? – android developer May 30 '12 at 11:25
  • you cannot pass any additional Informations inside the built in crashReport. You can use the DefaultExHandler ONLY to send your OWN Reports, in a way you like – Rafael T May 30 '12 at 11:30
  • 2
    you didn't understand me (because of me , i admit) . i want to put extra data . for example , suppose i get a null pointer exception , and i want to include logs that were printed before this exception occurred . can i add this info in some way , so that on the developer website i can see it together with the rest of the information that was gathered ? maybe i can send my own custom exception which include this data? – android developer May 30 '12 at 11:34
  • It may not satisfy you, but I think I understood you well. The answer, again, is no. If you want to get additional Infos you have to invent your own reports and send them to your own server! There Is no Api, or any other way to send SOMETHING, or to communicate to the build-in feature (if you dont wanna cook your own rom) – Rafael T May 30 '12 at 11:39
  • so if i call the original DefaultErrorHandler method to handle the exception , yet send my own exception there , with my own information , it won't work? – android developer May 30 '12 at 12:22
  • to clearify terminology: Javas DefaultExceptionHandler can be used to send yourself Anything of interest. You need your own server/service to do that, and you cannot send Your Exceptions to GoogleMarket. Googles-built-in sends any Exceptions that is not catched (or re-thrown) inside your app to the dev account. – Rafael T May 30 '12 at 12:28
  • well that's what i'm suggesting : i will catch the exception that was supposed to be sent further , and instead , i will throw my own exception . shouldn't it be a workaround of customizing what is sent to the crash report ? – android developer May 30 '12 at 12:38
  • If you see it like this, you're right. I never thought about this. – Rafael T May 30 '12 at 12:42
  • Yes, I see a good chance in doing this. The feature sends Exceptions to the market. I see no reason, why that cannot be your CustomExceptions. Only problem may be, that only stackTraces are send... – Rafael T May 30 '12 at 12:54
  • yes , i see your point , and i don't think that stack traces can be modified and simply have extra strings , right? i can see the stack trace on the demo video itself : http://www.youtube.com/watch?v=o8unC9bA4O8&feature=player_detailpage#t=44s – android developer May 30 '12 at 13:14
  • it may a be little hakish, but you can Cosntruct new StackTraceElements http://developer.android.com/reference/java/lang/StackTraceElement.html Any Exception has a setStackTrace Method. Tough you should be able to catch an Exception, get the StackTrace, add Your HackedCustomStackTraces, and rethrow that error – Rafael T May 30 '12 at 13:55
  • good idea . i will try to do it . thanks. if i succeed , i will give you a "V" and also publish some code. for now , i've given you a +1 . :) – android developer May 30 '12 at 14:03
  • it worked ! not sure what will occur on the developer website , but it worked ! i can even set the details of the excpetion via a CTOR (and maybe i should , instead of messing with the stackTrace) . thank you so much! – android developer May 30 '12 at 14:28
  • inside the Constructor you can define only one String. If thats sufficient to you, you should stick to that. The StackTrace 'injection' was just an option, to add more than one String :) Glad, that I could help you – Rafael T May 30 '12 at 14:31
  • how long can the string of the CTOR be? also , do you think it will show up in the report , and if it will handle "\n"...? – android developer May 31 '12 at 07:07
  • as long a String can be, and I think that it will show up inside the report, not shure, if it will handle CarriageReturns correctly – Rafael T May 31 '12 at 07:33
  • Curious on the result. Does it eventually shown on the report?@androiddeveloper – nuynait Aug 16 '17 at 20:20
  • I remember years ago, I could just extend `Application`, override the method responsible of processing logs (or something like that; maybe it was just for errors only? I can't recall), do my stuff (sending the log via mail etc.) and just call super or something similar... I am just struggling to find it again in the internet T_T – SebasSBM Apr 13 '22 at 00:30