I've seen other solutions for this but none of them seem to apply.
I'm trying to read from a process executing "logcat -d" and I'm receiving the error in the title.
My AndroidManifest.xml includes:
<uses-permission android:name="android.permission.READ_LOGS" />
Using adb shell, I can execute the command just fine.
This is a code snippet:
ProcessBuilder procBuilder = new ProcessBuilder();
procBuilder.redirectErrorStream(true);
procBuilder.command("logcat", "-d");
procBuilder.directory(new File("/"));
Process process = procBuilder.start();
//Process process = Runtime.getRuntime().exec("logcat -d");
process.waitFor();
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(process.getInputStream()));
StringBuilder log = new StringBuilder();
String line = "";
while ((line = bufferedReader.readLine()) != null) {
log.append(line + "\n");
}
When executed, I see the first line as the error in the title and that is all.
I've read online that logcat cannot be executed without su and yet there are plenty of articles of code just like this...working just fine.
Any other ideas of what I might be doing wrong or could try?