Collecting stacktrace of crashing widget with ACRA Android - android

I am trying to debug the widget of the app I'm developing with ACRA but I have a problem. I use the following code to collect the StackTrace:
import org.acra.ACRA;
import org.acra.ReportingInteractionMode;
import org.acra.annotation.ReportsCrashes;
import android.app.Application;
#ReportsCrashes(formKey = "",
resToastText = R.string.crash_toast_text, mailTo = "mailAddress", mode = ReportingInteractionMode.TOAST, logcatArguments = {
"-t", "100", "-v", "long", "ActivityManager:I", "MyApp:D", "*:S" })
public class MyApplication extends Application
{
#Override
public void onCreate()
{
super.onCreate();
// The following line triggers the initialization of ACRA
ACRA.init(this);
}
}
The problem is that it happens on Samsung devices that the widget become unresponsive after a random amount of time and I have no idea what is causing it (I never call onUpdate so nothing should happen but this is another story). I'd like to use ACRA to collect the StackTrace when it becomes unresponsive but when, for example, I turn on the screen after 10 minutes and see the widget not working I have no message from ACRA that has collected a crash report to send me an email and see the problem.
Is maybe ACRA not working?
If the widget is not responsive (the buttons for example) it means it crashed right?
Do you have any better strategy to debug this situation?
Thank you very much

If the widget is not responsive, then it hasn't crashed, it is in some kind of deadlock or waiting state. That is why you haven't received any message from ACRA.
Either looks at what the threads are doing, or injecting a healthy amount of debug to try to determine what has locked up the app.

Related

How to disable ANR Watchdog when generating Trace Logs for Profiling after instrumenting my App?

Currently trying to obtain profile trace logs files for a huge Android app, that we have instrumented on MyApplication class, following the documentation about instrumenting my app to get trace logs.
We are trying to dig into what happens when our app is initialized and Dagger2 creates the object graph when the app is started.
A cold startup can take a few seconds normally, the issue I have is that when I add the Debug traces, it dramatically slows down the initialization of the app, making it crash with an ANR message.
com.github.anrwatchdog.ANRError: Application Not Responding
Caused by: com.github.anrwatchdog.ANRError$$$_Thread: main (state = RUNNABLE)
I would like to know if there is a way to prevent the Android OS from crashing my app when it blocks for a long period of time, or to at least increase the ANR threshold.
Any help or tips are welcome. Thanks!
For further context, this is roughly what I am doing in my MyApplication.class:
public void onCreate() {
super.onCreate();
Debug.startMethodTracing("MyApp_onCreate()");
injectSelf();
AppInit.initApp(this);
Debug.stopMethodTracing();
}
Actually, it turns out we have our own ANRWatchDogManager which I wasn't aware of, where I can extend the limit.
public class ANRWatchDogManager implements ANRWatchDog.ANRListener {
Somewhere in that class:
public void startANRWatchDog() {
final int timeoutInterval = isDebugBuild() && isEmulator()
? ANR_INCREASED_TIMEOUT
: ANR_DEFAULT_TIMEOUT;
new ANRWatchDog(timeoutInterval).setANRListener(this).start();
}

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.

Android application not crashing when it should [ACRA]

Hi all,
I'm using (trying at the moment) ACRA for bug-reporting. Scenario is:
I open the app: ACRA outputs ACRA is enabled for mypackage, intializing...
I enter the Settings (where I prepared a NullpointerException)
The app freezes and Preparing crash dialog is output via a toast
The app does not close, but instead outputs the same toast again and again (all Views are gone)
When I close the app, after a few seconds (of gathering data I guess) the crash dialog opens
I have the following Annotation in front of my Application subclass:
#ReportsCrashes(formKey = "iwontshowyoumyformkey", customReportContent = {
REPORT_ID, APP_VERSION_CODE, ANDROID_VERSION, PHONE_MODEL, BRAND,
STACK_TRACE },
mode = ReportingInteractionMode.DIALOG,
resToastText = R.string.acra_toast_text,
resDialogText = R.string.acra_dialog_text,
resDialogTitle = R.string.acra_dialog_title,
resDialogCommentPrompt = R.string.acra_dialog_comment_prompt,
resDialogOkToast = R.string.acra_dialog_ok_toast,
forceCloseDialogAfterToast=true)
A notable detail is that the error occurs again and again, according to the Logcat.
This made me think that the activity is restarted all the time, and the error is in onCreate...
But the fact that the tag is ACRA made me unsure if it isnt ACRA, reoutputting the error.
Problem: The app should be crashed and closed so that the dialog can appear, but isn't.
Question: How would I go about debugging/solving this? A solution would be even better...
Thank you in advance,
Till
It's not solved, but I decided to not spend any more time on it, and abandon ACRA.
Crittercism has proven to be quite painless.

How to programatically change ACRA 'interaction mode' setting

I'm implementing ACRA in my Android App. I would like to be have it's interaction mode be silent by default, but if I see that a new version of my App is available, "Toast" the user upon crash with a message to update their copy of the App.
However it seems that ACRA interaction mode must be hard coded and loaded once upon init of application. Any way to set the mode at that point not via a hard coded setting? E.g. I'm looking to control the "mode = " setting which is copied below.
#ReportsCrashes(formKey = "xxxxxxxxxxxxxxxx",
mode = ReportingInteractionMode.TOAST,
resToastText = R.string.crash_toast_text)
public class MyApplication extends Application ...
I see that ACRA Issue 85 has added setters for resources for Toast parameters, but does it also have ability to configure interaction mode?
Maybe this? I didn't try but seems useful (at point of start)
http://www.java2s.com/Open-Source/Android/App/acra/org/acra/ErrorReporter.java.htm

Android App crashes in emulator - logs blank

I am completely new to android, and pretty much a Java newb.
I have a simple app that I am building to get the hang of android's development environment - and things like click events, etc..
The app loads, and I am able to change the text in a textfield using a button handler. However, when I import the location class, and try to do a simple GPS call, the application crashes.
The problem is, everything looks good in Eclipse (error console) - and I'm not seeing any exceptions in the android emulator (DevTools). I have the logcat window open, but I haven't done anything in eclipse/code to send logcat anything (do I need to?)
Can anyone see something wrong with this? Is there a better way to troubleshoot?
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.*;
import android.location.*;
public class locationDisplay extends Activity {
private EditText text;
private Location GPSLocation;
double dblLat;
double dblong;
String strLat;
/** Called when the activity is first created. */
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main); // bind the layout to the activity
text = (EditText) findViewById(R.id.EditText01);
text.setText("No button pressed");
}
// Handler for each button -- Button01 is when it crashes
public void myClickHandler(View view) {
switch (view.getId()) {
case R.id.Button01:
dblLat = GPSLocation.getLatitude();
strLat = Double.toString(dblLat);
text.setText(strLat);
break;
case R.id.Button02:
text.setText("Button 2 was clicked");
break;
case R.id.Button03:
text.setText("Button 3 was clicked");
break;
}
}
You shouldn't need to write anything to get the default messages in LogCat; uncaught exception reports should appear automatically when your program crashes. However, sometimes LogCat and your emulator get disconnected from each other and the messages simply all disappear. Simply close Eclipse and the emulator, restart them both, and the messages should reappear. An easy way to tell whether the link has been re-established is during the boot-up of the emulator. Just as the flashing "ANDROID" text in the fancy font disappears bringing you to the lockscreen, you should see about a hundred lines of text flash by on LogCat. If that doesn't happen, then LogCat isn't getting its messages.
The way to display debugging messages in Android is to use the Log.d("some name for your log statements so you can filter the LogCat messages", "The actual debug statement here");. You'll often find people using things like a static final String LOG_TAG in their application so that they can make sure their logs always have the same tag, and hence, the filter never misses a message.
As for your actual code here, Rpond is right, you never initialised your GPSLocation object.
You GPSLocation object is null. You need to access the LocationService to get a current location. And with the emulator you will need to manually send locations.
Location Services
Sometimes LogCat 'forgets' you have a device/emulator connected and running. It seems like this happens after you have a device and an emulator online at the same time and then you disconnect one of them. If you are getting nothing from LogCat, go to Window>Show View>Other>Devices and then click the device that you want to log.

Categories

Resources