Just started using ACRA. When the application crashes it sends a report to my server. All is well.
But there are exceptions which I can catch and let the user keep the problem without error - like using default values. But I'd like to get an error report without bothering the user. But when I do:
ErrorReporter errorReporter = ACRA.getErrorReporter();
errorReporter.putCustomData("test", "value");
errorReporter.handleSilentException(null);
the application shuts down. I first tried throwing some error (testing purposes), I hoped sending null
would stop the app from stopping - I was wrong.
Is there a way to use ACRA to send an error report without exiting the app? Just thought I had it, but
ErrorReporter errorReporter = ACRA.getErrorReporter();
errorReporter.putCustomData("test", "value");
errorReporter.handleException(null, false); // false is endApplication param, `null` seems to result in a NullPointerException
This also closes the application (without an additional Exception from ACRA):
ErrorReporter errorReporter = ACRA.getErrorReporter();
errorReporter.putCustomData("test", "value");
errorReporter.handleException(new RuntimeException("message"), false); // tried `true` also, just in case
Also closes the app
Update:
(1) LogCat shows no stack trace.
(2) While reading the error report, my eye fell on
"DUMPSYS_MEMINFO":"Permission Denial: can't dump meminfo from from pid=1416, uid=10048 without permission android.permission.DUMP\n"
Tried to add android.permission.DUMP
to androidmanifest.xml
, but I get Permission is only granted to system apps
. Reason for exiting app? Work around? It gets all information that I need (and more)...
As it turns out, the above code is correct. The problem was in that I have overwritten the ErrorReporter
:
new HttpSender(org.acra.sender.HttpSender.Method.PUT, org.acra.sender.HttpSender.Type.JSON, null) {
@Override
public void send(final Context context, final CrashReportData report) throws ReportSenderException {
super.send(context, report);
respondAsIfCrashing(); // not the real method name
}
};
The application wasn't crashing, it just appeared to do that, because of the respondAsIfCrashing
method.
The warning DUMPSYS_MEMINFO":"Permission Denial: can't dump meminfo from from pid=1416, uid=10048 without permission android.permission.DUMP
is, apparently, not a reason to crash... (perhaps just not writing to device?)
So using
ErrorReporter errorReporter = ACRA.getErrorReporter();
errorReporter.handleException(new RuntimeException("message"), false);
Is sufficient