1

The logcat process is launched, I don't get any error or force close. It simply seems to not generate any output.

    String commandLine = "logcat -v time -b main *:V";
    String line;

    try {
        process = Runtime.getRuntime().exec(commandLine);
        bufferedReader = new BufferedReader(new InputStreamReader(process.getInputStream()));

        while(!mStop && (line = bufferedReader.readLine()) != null && newMessages.size() < maxMessages) {
            // It does not reach this point
            // Debugger shows 
            // mStop == false
            // newMessages.size == 0
            // maxMessages == 5000
            // line == null

The suspicion is that logcat exits wihtout printing anything out. I tried this in a command line and it does output logcat messages.

I replaced logcat with ls and then bufferedReader does fill line.

The inspection of bufferedReader shows member in(InputStreamReader) which itself has a memeber endOfInput which is false before the readLine() and becomes true right after it.


LAST NEWS: I opened the Terminal Emulator within the emulator itself, and run it:

$ logcat -v time -b main *:V
Unable to open log device '/dev/log/main': Permission denied
$
ilomambo
  • 8,290
  • 12
  • 57
  • 106

1 Answers1

4

After looking for similar post it seems this is quite a duplicate from:

Android unable to run logcat from application

In short, the problem was: a user permission is required to read logs, so I added:

<uses-permission android:name="android.permission.READ_LOGS" />

to the manifest and it works fine now.

Community
  • 1
  • 1
ilomambo
  • 8,290
  • 12
  • 57
  • 106