I'm trying to write an app that reads all logs on my device. I've got a client/service architecture, and I see log messages from both the client and service processes but I don't see any messages from any other applications on the phone (I do see other messages using the desktop logcat).
Do I need root?
<uses-permission android:name="android.permission.READ_LOGS" />
Runtime.getRuntime().exec("logcat -c").waitFor();
Process process = Runtime.getRuntime().exec("logcat -v long *:*");
BufferedReader reader =
new BufferedReader(new InputStreamReader(process.getInputStream()));
while (true) {
String nextLine = reader.readLine();
if (!nextLine.contains("LogWatcher-D")) {
Log.w("LogWatcher-D", "See: " + nextLine);
}
// Process line
}
To gather logs (logcat) from an android phone, follow either one of the following processes. Install Android SDK from http://developer.android.com/sdk/index.html. Make sure platform-tools is included (http://developer.android.com/sdk/installing/adding-packages.html). Enable USB Debugging on your device.
Navigate to device settings and enable Developer Options (see section for ADB logs) Navigate to Developer Options and tap on Take/Submit Bug Report. Select Full Report when prompted to get the full device info along with the logs.
Solution 1: Restarting your Android StudioIn your IDE Go to File > Invalidate Caches and Restart > Invalidate and Restart. This Solution will clear all the caches of Android studio IDE and restart it automatically, By the method, there are 80% change that Logcat will start work as before.
On Android 4.1+, you can only access log messages logged by your process, unless you hold the READ_LOGS
permission. That permission requires either that your app be signed by the same signing key that signed the device's firmware, or that your app is installed on the system partition.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With