Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

android studio error disappears in logCat after crash

My app is crashing. For a split second the error appears in the logcat but then very quickly gets replaced by a bunch of garbage. How do I find my error? My error seem to scroll off so quickly that I cannot find it.

like image 614
Katedral Pillon Avatar asked Jun 26 '15 03:06

Katedral Pillon


Video Answer


2 Answers

Currently I filter logs in Logcat so (insert you package name):

enter image description here

Check that you selected "No filters" in the right box. Sometimes it will be useful to change to other options (like "Firebase", "Show only selected application") and return to "No filters". Maybe wait for 5-10 seconds.

I found that Pixel 2 emulator with Android 5 (API 21) didn't show logs. So, it would be better to create Nexus 5/5X emulators instead.

Also there is another way. See Android Studio, logcat cleans after app closes.

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.

So you can write your package name inside a Log Message field. To do this, in LogCat press Edit Filter Configuration

enter image description here

and set log message:

enter image description here

like image 146
CoolMind Avatar answered Sep 23 '22 13:09

CoolMind


In my experience, I just discovered that I have this option available in the logcat each time my app crashes (See image). Even if it crashes, it will display the default app package name (the one with the yellow arrow). So you will have to select the package name [DEAD] option from the dropdown (with Yellow Check) and then select ERROR (encircled in blue). and the errors should display.

logcat_screenshot

like image 33
embc12 Avatar answered Sep 25 '22 13:09

embc12