70

I am using Android Studio 1.5.1 and it clears the logcat buffer during app restart. Now my app crashes, restarts and I don't see what happens just before the crash.

Is there a way for logcat in Android Studio not to clear during the app restart? I wanted to increase the logcat buffer size, but could not find the option it in the current version of AS.

mmBs
  • 8,421
  • 6
  • 38
  • 46
jpou
  • 1,935
  • 2
  • 21
  • 30

2 Answers2

131

I had the same issue, but looks more like a feature than a bug:

In AndroidStudio, the default setting for the Logcat window seems to be "Show only selected Application" (top right corner of the Logcat window)... which is looking at the log of the selected process (your current launch by default). So when your app crashes during testing, that process is gone, so the filter clears the log.

Instead, select "Edit Filter Configuration..." and set up a filter for your app, eg:

  • FilterName: MyApp
  • PackageName: com.example.myapp (<< replace with your app's package name)

...and then select that filter for future runs. This should keep the log there for you, even after the app crashes.

duplicate

Community
  • 1
  • 1
Sinkeat
  • 1,490
  • 1
  • 13
  • 10
  • 4
    Is there a way for preventing the app from restarting instead? – Davide Apr 13 '20 at 12:54
  • 3
    the great hack I think – Noor Hossain Dec 27 '20 at 14:52
  • While this is a solution, I've got the feeling that clearing the log was not a default setting before they changed something. I always thought that this was happening because I was using Crashlytics, that Crashlytics somehow intercepted the crash and somehow redirected the output to send it to Google, and while doing that, it cleared the log. The thing is, that if I let the app crash a second time, then the log won't get cleared, so I usually repeat the crashing condition to get access to the log (very annoying). – Daniel F Feb 08 '21 at 11:40
10

In the device's developer settings, locate the option for "Always show crash dialog" and enable it:

"Always show crash dialog" enabled in developer options

By doing so, the application will not be restarted and the log for the process (before it died) will not be cleared in Android Studio.

Paul Lammertsma
  • 37,593
  • 16
  • 136
  • 187