10

I recently noticed, that my app doesn't crash when an uncaught exception occurs, but it is not responding. I use Google Analytics to get insight of crashes, I suspect that this may be the cause of the problem.

When I throw a NullPointerException in onCreate() (immediately after super.onCreate()), the app shows a white screen, but it doesn't crash.

Logcat says:

06-30 14:00:59.386  26259-26259/? I/GAv4﹕ Google Analytics 7.5.71 is starting up. To enable debug logging on a device run:
    adb shell setprop log.tag.GAv4 DEBUG
    adb logcat -s GAv4
06-30 14:00:59.398  26259-26259/? W/GAv4﹕ AnalyticsReceiver is not registered or is disabled. Register the receiver for reliable dispatching on non-Google Play devices. See http://goo.gl/8Rd3yj for instructions.
06-30 14:00:59.409  26259-26259/? W/GAv4﹕ CampaignTrackingReceiver is not registered, not exported or is disabled. Installation campaign tracking is not possible. See http://goo.gl/8Rd3yj for instructions.
06-30 14:00:59.414  26259-26295/? W/GAv4﹕ AnalyticsService not registered in the app manifest. Hits might not be delivered reliably. See http://goo.gl/8Rd3yj for instructions.
06-30 14:00:59.467  26259-26259/? D/AndroidRuntime﹕ Shutting down VM

I would like to see the uncaught exceptions, because it's really hard to fix them if I don't see the stacktrace and the reason of the problem.

What can I do to get back the previous behaviour?

EDIT: After removing Analytics error reporting (not calling tracker.enableExceptionReporting(true);), I get the crashes again. I use Analytics from Play Services 7.5.0.

hunyadym
  • 2,213
  • 25
  • 39

2 Answers2

1

Google Analytics is the culprit. Try disable it (or disable automatic reporting of uncaught exceptions) while you are developing and enable it when you sign your app with the release key.

Frederick Nyawaya
  • 2,285
  • 1
  • 15
  • 19
  • For me the app didn't crash neither signed with debug nor with release key. (As I noted in the question, I ended up with disabling Analytics exception reporting.) – hunyadym Oct 15 '15 at 11:46
-1

The Exceptions are shown in Console by default.

If you don't want to check the Console (I think is more handy for this purpose because Logcat is sometimes a big mess), then just show the Exceptions in the Log when catched.

try {

} catch (Exception e) {
    Log.e("YOUR_APP_TAG", "Exception occured: ", e);
}
Jordi Castilla
  • 26,609
  • 8
  • 70
  • 109
  • Where can I access this Console? (I'm using Android Studio.) Also, in Play Store, I don't get any crash reports, only ANR reports, which doesn't contain the stacktrace. I also don't want to wrap all my code with try-catches. – hunyadym Jun 30 '15 at 12:23
  • AFAIK you don't have any other option than manually redirect the exceptions... **You still can take a look at the console eh!!!** But you don't need to use millions of `try-catches` if you controll all `Exception` that may occur into a general `Exception` catcher/handler... – Jordi Castilla Jun 30 '15 at 12:24