209

I'm having a problem with my logcat since update 1.2 Beta for Android Studio. When I run my app it logs everything like it normally did, then I get at the point where my app crashes with the app saying: unfortunately, Game has stopped.

After a few seconds android closes that message. When that happens my logcat also gets fully cleared meaning that I barely get anytime to read the error. I did found some info about a buffer, but it seems that Android Studio doesn't have the option to increase it besides the fact that I doubt that being the problem.

Something that may be useful is that after it clears and stuff the process changes to Android.process.core and the message I get in my logcat is:

04-13 10:28:13.394  12259-12265/android.process.acore D/dalvikvm﹕    
Debugger has detached; object registry had 1 entries

Edit: I did read about breakpoints, so disabled focus application on breakpoints in Settings-build, execution, deployment-debugger but it didn't have any effect.

mmBs
  • 8,421
  • 6
  • 38
  • 46
Black Lotus
  • 2,377
  • 3
  • 14
  • 18
  • 2
    If you find the installed location of the adb program you can run `adb logcat` from your terminal or command window, and optionally pipe it into a pager, grep, tee, or whatever. – Chris Stratton Apr 10 '15 at 19:13
  • 1
    yes, also you may try `adb shell bugreport > log.txt`, kinds of log info would be fetched once the command finished. – yummy Apr 10 '15 at 19:15
  • @yummy worked out the best for me for now, still hope to find a fix since this isn't the best way in my opinion. Thanks – Black Lotus Apr 11 '15 at 09:54
  • 1
    I didn't find any solution to not have the logs cleaned with Android Studio 1.2 but an easy solution is to not click on the close button (onto the device) when the app crashes. Thus, you have all the logs, and the reasons why the apps crashed. – Chakir May 28 '15 at 19:34
  • @Jameltheone The messages only stays on screen for a couple of seconds.then it closes the crash dialogue itself. So don't really have control over that. – Black Lotus Jun 01 '15 at 16:35

14 Answers14

416

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.

maxdownunder
  • 5,629
  • 3
  • 19
  • 21
85

Switch "Show only selected application" to "No filters". This way, you can see logcat output from a process even when that process isn't running.

The downside is that your logcat will be filled with more spam from other processes.

Brian Attwell
  • 9,239
  • 2
  • 31
  • 26
34

In case of crash see the Run tab at the bottom of IDE.

You can see the crash reason in this part (even in logcat clean case).

Note: If the above trick not works try to produce a crash and immediately disconnect the mobile cable (if you use the real device for the test). you can see the error before it cleaned.

Update: If also above trick not works, try to attach and detach phone and hopefully problem solved.

Update2: If again not work, try to Invalidate catches and Restart then start debugging again.

Update3: As The last way, try to remove the app and install it again then start debugging (if you do not lose that condition you want to test)

Amir Hossein Ghasemi
  • 20,623
  • 10
  • 57
  • 53
30

My App was crashing and restarting. I also had some problems on reading the logcat to know what was happening. I then noticed that in the drop down menu, next to the Device dropdown it had something like "com.mypackage.myapp ('some number')" and when my app crashed there was another option that said "com.mypackage.myapp ('some number') [DEAD]". If you select the "Dead" option, it will show you the logcat of the previous instance.

Dead LogCat

ALourenco
  • 439
  • 5
  • 10
15

Might be very late to the party but I had the same problem and solved like this:

In logcat window, top right corner drop-down menu select Edit filter configuration, on the next menu, introduce Filter name and your Package name.

Done, for me it keeps logs visible after crashing.

codeKiller
  • 5,493
  • 17
  • 60
  • 115
9

In Android Studio 2+

  1. Click Run

  2. Click Edit Configurations

  3. In the Run/Debug Configurations window select the Miscellaneous tab

  4. Make sure the Clear log before launch checkbox is not checked

Flot2011
  • 4,601
  • 3
  • 44
  • 61
5

The filter clears the log once the app gets crashed. So select "Edit Filter Configuration" and create your own custom filter with filter name. This will save the log with informations even when the app is crahed.

Mohammed Nishar
  • 171
  • 3
  • 12
5

I'm Working with Android Studio 4.0 enter image description here

  1. Go to Edit Configuration of your app.
  2. Go to Miscellaneous Tab
  3. Uncheck the field Clear log before launch.
  4. Press OK. It'll work..
4

i have faced the same issue and this is the solution :-

1- Tools --> Android --> Enable ADB Integration.

and now you can see the logcat and the crashes as normal

Ziad Gholmish
  • 861
  • 1
  • 9
  • 10
  • My ADB intergration was already enabled sadly enough. Something that is maby usefull is that after it clears i get the message: 04-13 10:28:13.394 12259-12265/android.process.acore D/dalvikvm﹕ Debugger has detached; object registry had 1 entries – Black Lotus Apr 13 '15 at 08:34
  • @BlackLotus have you solved your problem? I face the same problem [here](http://stackoverflow.com/questions/33645716/debugger-has-detached-object-registry-had-1-entries-in-android-studio?noredirect=1#comment55065701_33645716) – Hoo Nov 11 '15 at 09:20
  • This is no longer valid in the new Android Studio. – Hamzeh Soboh May 13 '20 at 22:08
2

It is 2018 and this can still happen. Close Android Studio and reopen.

straya
  • 5,002
  • 1
  • 28
  • 35
2

7 years later ...

I still have same issue on AS ArcticFox and nothing helps.

But I have found one workaround.

  1. make sure this is enabled:

enable_mesages_in_run_console

  1. Then you can see your logs regardless the app is alive or not or device is connected or not. Which is great!

enter image description here

Alexander Skvortsov
  • 2,696
  • 2
  • 17
  • 31
1

Still, sometimes I get this problem although some solutions work here such as restarting android studio it takes time.

Here I found how to get error message without restarting the studio

  1. Launch the app
  2. Be on run tab before you make your reproduce crash
  3. Click on the content of run tab as soon as crash occurs (if you don't click on content you will lose error report)
AgentP
  • 6,261
  • 2
  • 31
  • 52
0

This bug seems to be fixed with the new release of Android Studio version 1.2.2

Chakir
  • 488
  • 4
  • 10
  • 1
    The bug is still here, even in Android Studio 2.2.2, so I guess @maxdownunder was quite right with the assumption that it is indeed a... "feature" – techfly Nov 02 '16 at 13:23
0

I ran into the same problem and none of the answers could help me, until I realized my app was causing an OutOfMemoryException. That's a probable root cause as well.

Chisko
  • 3,092
  • 6
  • 27
  • 45