Android Studio missing exception stacktrace in Logcat

7.4k views Asked by At

For some time, Android Studio doesn't show me stacktrace when developed application crashes. All I can see is following line:

06-09 16:12:36.875  26037-26037/com.a.b W/dalvikvm﹕ threadid=1: thread exiting with uncaught exception (group=0x4206c700)

This drives me crazy because I cannot see, where application really crashed (and what exception occurs). I'm using AS 1.3 Preview 2. At first I though there is problem with dependencies, but now I'm using just these and problem still occurs:

dependencies {
  compile fileTree(dir: 'libs', include: ['*.jar'])
  compile 'com.android.support:appcompat-v7:22.2.0'
  compile 'com.google.android.gms:play-services-base:7.5.0'
  compile 'com.google.android.gms:play-services-analytics:7.5.0'
  compile 'com.jakewharton:butterknife:6.1.0'
}

Problem is probably based on fact that application doesn't crash, but only freeze.

Thanks for every suggestion.

4

There are 4 answers

4
Radim Vaculik On BEST ANSWER

Try to remove all dependencies in your build.gradle file. IMHO, the bug will be in play-services-analytics. Google Analytics tracks exception. Try to remove tracker.enableExceptionReporting(true) in your code.

2
Bidhan On

The same thing started happening to me after I updated my Android Studio. After hours of frustration, I found out that clicking on the Filter dropdown menu on the right side of the logcat screen and clicking on No Filters, even if it's already set to No Filters, fixes the issue. I don't know if it will work in your case but you might as well give it a try if you haven't already.

0
Mick On

For me the issue was that Android studio was showing logs from a restarted version of the app rather than the one that just died.

To see the stacktrace from the app version that has died, there is a drop down on the right of the logical window which allowed me select the logs from the dead app:

enter image description here

This then showed the correct stracktrace.

0
Dan Fabulich On

Elaborating on Radim's answer, logcat doesn't show exceptions that are handled by the setDefaultUncaughtExceptionHandler for the main thread.

You probably use an analytics library that registers itself as the default UncaughtExceptionHandler.

Note that, this doesn't only apply to uncaught exceptions, but also to exceptions that you log with android.util.Log. Code like this should log an exception, but will only show the "Failed" message:

try {
  something();
} catch (Exception e) {
  Log.v(LOG_TAG, "Failed", e);
}

Logcat will show this, with no stack trace, regardless of whether you use Log.w, Log.e, etc.

V/MyApp: Failed

Radim called out play-services-analytics as a common culprit, but Google's new analytics library is firebase-core; it has the same problem. I fixed it by disabling analytics collection on debug builds.

I changed this line:

FirebaseAnalytics.getInstance(this);

to this:

FirebaseAnalytics.getInstance(this).setAnalyticsCollectionEnabled(!BuildConfig.DEBUG);

Thus, when I run debug builds in development, Firebase analytics doesn't handle exceptions, and I can see them in logcat.