Unable to get responses in ACRA Crash report after first response - android

i have being using ACRA ,which is a library enabling Android Application to automatically post their crash reports to a GoogleDoc form.
i have been using following code in OnCreate of Application
#ReportsCrashes(formKey = "XXXXXXX", mode=ReportingInteractionMode.TOAST,
forceCloseDialogAfterToast = false,resToastText = R.string.crash_toast_text)
public class MyApplication extends Application{
#Override
public void onCreate() {
// The following line triggers the initialization of ACRA
ACRA.init(this);
super.onCreate();
}
}
When i First test it i got response in ACRA CrashReport form(In form of Google Doc) but for next time for same crash i didnt get response whenever any crash/exception occur in my android application.

Check that you set all permissions needed ACRA. It depends on fields that you want in report, some of them need READ_LOGS permission or READ_PHONE_STATE permission
(for more http://code.google.com/p/acra/wiki/ReportContent)
If error still present and connected with report sending on Google Doc try to add custom timeout:
#ReportsCrashes(formKey = "xxxxxxxxx", socketTimeout = 25000)

Related

Disable/Enable Firebase Crashlytics during runtime

With Google sending out waves of warnings about the need to let users opt-in to crash reporting (source) I'm trying to build an opt-in dialog for Firebase Crashlytics.
To be able to do this I would need to know whether Crashlytics is currently enabled (to decide whether to show the dialog or not). It seems CrashlyticsCore.disabled is responsible for tracking this but I haven't found any way to access the value because it's package private and doesn't have an accessor. How can I know during runtime if Firebase Crashlytics is enabled?
The second thing I'd need to do is disable crash reporting by default and enable it when the user agrees to opt-in. How I suspected to be able to do this:
AndroidManifest:
<meta-data
android:name="firebase_crashlytics_collection_enabled"
android:value="false" />
Activity:
boolean userAgrees = true;
CrashlyticsCore core = new CrashlyticsCore.Builder().disabled(!userAgrees).build();
Fabric.with(this, new Crashlytics.Builder().core(core).build());
throw new RuntimeException("why doesn't this show up in Firebase Crashlytics?");
Why isn't my RuntimeException showing up in Firebase Crashlytics?
P.S. Crashlytics is working fine when removing these attempts to create an opt-in dialog.
It seems toggling Crashlytics will only take effect after your app restarts. Fabric is a singleton and all calls to its Fabric.with method will simply be ignored after it's been initialized. Source code below.
public static Fabric with(Context context, Kit... kits) {
if (singleton == null) {
Class var2 = Fabric.class;
synchronized(Fabric.class) {
if (singleton == null) {
setFabric((new Fabric.Builder(context)).kits(kits).build());
}
}
}
return singleton;
}
One way around it is to keep track of the value yourself using SharedPreferences or other persistent storage methods and update your UI accordingly.

Initialise Crashlytics error reporting by itself without Answers etc

I want to initialise CrashlyticsCore, which just has error reporting, not Crashlytics, which has automatic built in usage reporting.
I have found this answer:
How do i initialize the new version of crashlytics?
Which says to do this:
Fabric.with(this, new CrashlyticsCore.getInstance());
I am not sure whether the "new" keyword is meant to be there. However, with or without "new", it gives the following error:
java.lang.IllegalStateException: Must Initialize Fabric before using singleton()
Does anyone know how to just initialise CrashlyticsCore without Crashlytics?
You can try the answer in this thread
Fabric.with(this, new Crashlytics.Builder().core(new CrashlyticsCore.Builder().build()).build());
Or you can create a method that only enables sending Answer events based on a boolean flag:
public static void logCustom(boolean isEnabled, String eventText) {
if (isEnabled) {
Answers.getInstance().logCustom(new CustomEvent(eventText));
}
}

Why ACRA library throws Exception Dialog Even app is not running currently?

I want to add ACRA library to report exception to app developer but This code working fine when app is running currently but it's shows exception even app is closed.
import org.acra.ReportingInteractionMode;
import org.acra.annotation.ReportsCrashes;
#ReportsCrashes(formUri = "",
mode = ReportingInteractionMode.DIALOG,
mailTo = "xyz#gmail.com",
resDialogText = R.string.reporttous,
resDialogOkToast = R.string.OK,
formKey = "")
public class UILApplication extends Application {
#Override
public void onCreate() {
super.onCreate();
ACRA.init(this);
}
}
Any hint or help will be appreciate
ACRA catches crashes that occur within your app and then optionally notifies user and sends you a crash report. It does so by catching uncaught RuntimeExceptions and processing them.
If ACRA has caught an Exception and displayed a notification dialog, it is because your app was running and threw an uncaught exception.
Do not be confused with not visible in foreground and not running. They are not the same thing.

acra - send custom message

I tried to send a custom data with acra(and without crashing my app) with these 2 lines
ACRA.getErrorReporter().putCustomData("myKey", "myValue");
ACRA.getErrorReporter().handleException(null);
But in the report that I received was just:
Report requested by developer
The problem is that in my report there was no "myKey" or "myValue". How can I fix that? Maybe the problem is that I didn't include some specific Report Fields?
After that I tried with just
ACRA.getErrorReporter().handleException(null);
and it worked as with 2 lines above??
ACRA is designed to capture unhandled exceptions. It also provides functionality to silently send handled exceptions. Sending null is way outside its design parameters.
Try sending an actual exception.
I did a little workaround to group specific messages sent by it's exception. I introduced "FakeException" and removed stack trace so the message would be smaller.
public class FakeException extends Exception {
#Override
public Throwable fillInStackTrace() {
return null;
}
#Override
public void setStackTrace(StackTraceElement[] trace) {
super.setStackTrace(null);
}
}
Now You can create another Exception that extends FakeException and do something like this:
public void SendUserReport(String reportText){
ACRA.getErrorReporter().putCustomData(USER_REPORT_CONTENT_TAG, reportText);
ACRA.getErrorReporter().handleSilentException(new NotificationFromUserFakeException());
ACRA.getErrorReporter().removeCustomData(USER_REPORT_CONTENT_TAG);
}
The following picture shows this report in Acralyzer (awesome software, definitely use it).

ACRA send report without exiting app

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

Categories

Resources