Logcat crashes with error: unexpected EOF
Asked Answered
W

16

136

I’m running some lengthy calculations and something goes wrong quite late. I tried using breakpoints, but with no success so far. So I put into the loop a Log.d to monitor...

But quite soon, Logcat crashes with:

02-08 16:35:42.820 2936-3402/com.nohkumado.geneticsolving.full D/BaseC: 
    norm:BC sq:49.0 dis:0.0 con:50.0/BC sq:56.0 dis:4.0 con:94.0=1.4069148936170213

    read: unexpected EOF!

    --------- beginning of crash

and I need to restart the studio to get Logcat running again.

I looked if I could find some setting for the buffer size for Logcat, but so far I’ve found nothing. What can be done?

Wain answered 8/2, 2018 at 16:11 Comment(2)
The asker is conflating two unrelated things. The message "beginning of crash" means an Android app crashed, not logcat. The "read: unexpected EOF!" does actually come from the logcat process and it indicates that the logcat process lost its connection to the logd process.Encarnacion
Well, the app didn't crash, it was only not converging.... but i couldn't see it because of the buffer limitation of the logcat.....Wain
P
135

Try setting Logger buffer sizes to off under Settings->Developer options, on your device/emulator. This might be happening because Logger buffer is configured to display limited KB of logs only at a particular time. Next set of logs would only be displayed once previous buffer is cleared.

Pitiless answered 9/2, 2018 at 11:22 Comment(5)
indeed, the logcat on the tablet side, was of fixed length!Wain
I turned it off, now I don't see any logs, at all. (Samsung Note 8). I don't think this is a solution for everyoneNoellenoellyn
I turned it off but i still got the error as the question opener.Volney
this worked for me(with the emulator). the issue started just lately.Rejoinder
This shouldn't be an approved answer, it is better to increase the buffer to prevent it from depleting instead of turning it off on the real devices. Though it might be device dependent/ Android OS version dependent.Salmon
H
225

Fuller answer

The accepted answer didn't work for me. Rather than turning the logger buffer off, I increased it to the max size.

  1. Enable developer options in your emulator or device (not Android Studio) if it hasn't been enabled already: In your emulator or device go to Settings > System > About (emulated device) and click on Build number 7 times.
  2. Go to Settings > System > Developer options > Logger buffer sizes and choose a higher value.

enter image description here

  1. I also had to restart the emulator.

So the original problem apparently happens because the devices log buffer gets filled up for lengthy logging. Increasing the buffer size allows you to log more in a single logging session.

Honeydew answered 5/7, 2018 at 4:5 Comment(4)
Using this I can avoid the problem in a normal work day. There is an exception for me : using a Samsung phone in an environment with lots of Bluetooth devices. Samsung decided to log every Bluetooth scan in system level and apparently 16M is not be enough for this. It will still happen like 4 or 5 times a day when I have over 30 Bluetooth devices around me.Bedtime
The logd buffer is a ring buffer, changing it's size should have no measurable impact on whether the connection between logcat and logd is lost. All it does is change how much logging history sits around in memory. It's highly unlikely this fixes the problem.Encarnacion
@satur9nine, I can't say whether it fixes the problem at the underlying level, but it fixed my problem in that it prevented the crash and allowed more log messages to be shown.Honeydew
After transferring a TWRP backup from one Moto G5 Plus to another, my logcat buffer consisted of some events from months ago, some events from today, followed by read: unexpected EOF!. Increasing to 16M fixed the problem and made the months-old events disappear.Natalia
P
135

Try setting Logger buffer sizes to off under Settings->Developer options, on your device/emulator. This might be happening because Logger buffer is configured to display limited KB of logs only at a particular time. Next set of logs would only be displayed once previous buffer is cleared.

Pitiless answered 9/2, 2018 at 11:22 Comment(5)
indeed, the logcat on the tablet side, was of fixed length!Wain
I turned it off, now I don't see any logs, at all. (Samsung Note 8). I don't think this is a solution for everyoneNoellenoellyn
I turned it off but i still got the error as the question opener.Volney
this worked for me(with the emulator). the issue started just lately.Rejoinder
This shouldn't be an approved answer, it is better to increase the buffer to prevent it from depleting instead of turning it off on the real devices. Though it might be device dependent/ Android OS version dependent.Salmon
P
37

In Developer options you can set Logger buffer size to maximum 16M.
(Setting > System > Developer options > Logger buffer sizes)

If you need more you can set it using adb. For example you can set it to 100M:

adb logcat -G 100M
Penetration answered 8/5, 2019 at 8:1 Comment(0)
B
13

This log you posted is stating the app crashing (although not in the usual way with a stacktrace but it's crashing), not the logcat. Do you have the app selected and filter set to "Show selected application" in the logcat? If so just set the filter to "No Filter" and you'll see all the logs of your app.

Also in case you need to restart the logcat for any reason, rather than restarting Android Studio you could run the following commands which will restart adb and eventually restart your logcat as well:

adb kill-server
adb start-server
Barnie answered 8/2, 2018 at 16:35 Comment(3)
that is strange, because the app seems to continue working? i am usure about the computation itself (hence my wish to debug it) but the rest works, clicking on buttons etc continues to yield the expected behaviour? the adb trick restored the logcat, unfortunalely is skips then to the actual time point...Wain
I thought what u meant by lengthy calculation and then something goes wrong meaning the app is probably becoming laggy or not responding and then crashing. Is the app composed of multiple activities? And when the error happen is it like returning back to a previous activity? No filter doesn't show all the logs right?Barnie
No the app runs smoothly its the results that at some point deviate from the expected, yes several activities and the worker threads are done with async tasks, and no after that crash msg, logcat remains bland for everything....Wain
R
7

use the following command:

adb logcat -G 20M
Rigid answered 2/11, 2020 at 15:14 Comment(0)
U
7
  1. remove all log.d and restart android studio and Just go to File -> Invalidate Caches / Restart.
  2. your device Settings->Developer options
  3. Change Log Buffer size
Unremitting answered 30/3, 2021 at 6:13 Comment(0)
A
6

The recommendations did not work for me. I finally changed this preference setting:

Menu "Run", Menu Entry "Edit Configurations", then on the left side "Android App/app" and on the right side the tab "Miscellaneous", and finally activate "Logcat: Clear log before launch".

Of course this has side effects, but at least I can see the log output again.

Abate answered 28/10, 2020 at 22:10 Comment(0)
L
3

If you are running from a real phone - disconnect & connect the phone from the usb worked for me (the buffer gets empty- like @Suragch suggested).

Limicolous answered 6/8, 2018 at 18:34 Comment(0)
C
3

Changing the buffer size did not work for me. What did was changing my USB connection to a USB 3.0 port.

Convalescence answered 6/4, 2019 at 17:24 Comment(2)
Wonderful! Thank you for this hint. I had the same issue.Pontius
In the same vein also remove any USB hubs sitting between your device and your computer and/or try different USB ports on your computer.Encarnacion
S
3

Restart your device! I have no idea why it works for me after restarting my mobile phone.

Schizont answered 14/5, 2019 at 8:2 Comment(0)
B
2

Clear logcat

Others answers like increasing logcat memory will work. But after reaching certain threshold like 16mb, then same eof! file error would occur. So you can clear logcat in case. This issue won't occur after that. Even after clearing logcat also this issue occured means,you can increasing log buffer sizes.

Biannual answered 24/5, 2023 at 14:2 Comment(0)
S
1

adb logcat -G 1m

Enter this on Terminal, it worked for me

Skeens answered 28/12, 2018 at 14:22 Comment(0)
A
1

Unfortunately this seems to be still an issue, i could not find a satisfying solution beside of installing a plugin(File -> Setting -> Plugins -> Marketplace) called "Log Viewer". Works better than the built-in logcat viewer of Android Studio.

Alkyd answered 28/12, 2019 at 0:47 Comment(0)
S
1

just click on delete button and clean the past logs of your application

Just click on delete button and clean the past logs of your Application

Hope you get it.Thanks

Sunbow answered 13/9, 2022 at 17:36 Comment(0)
T
0

I had the same problem as a result of reading a texting file in a while loop. I had two log.d statement in the while loop and the file size was ~220 MB. I removed the log.d statement in the while loop because it was making so many outputs in logcat. I increased the logcat size to the maximum possible. That worked for me although the processing time was long before I got the desired result.

Taproot answered 22/1, 2021 at 11:52 Comment(0)
K
-1

Just go to File -> Invalidate Caches / Restart will let android studio do the job

Kornher answered 1/8, 2019 at 6:49 Comment(2)
I don't think this will help with the problem itself, but the AS restart will restart logcat, apparently fixing the problem.Hispanicize
@PNDA why not let android do validate your caches and restart it for u? I don't see where is the disadvantageKornher

© 2022 - 2024 — McMap. All rights reserved.