0

I am not using Android Studio, so when coding or debugging an application, I send the .apk with:

adb install -r test.apk

and run it. Recently, since using Thread, I get a Unfortunately, app has stopped crash. I tried to use:

adb logcat

but it is totally impossible to see anything in it, because I see hundreds of lines per second, and it never stops.

How to display only messages associated to a specific .apk with adb logcat?

On Linux, a grep could probably work, but I doubt it would work with adb on Windows (that I am using).

ZIA ANSARI
  • 131
  • 1
  • 11
Basj
  • 41,386
  • 99
  • 383
  • 673
  • 1
    try this [link](https://stackoverflow.com/questions/6854127/filter-logcat-to-get-only-the-messages-from-my-application-in-android) – Jyoti JK Dec 14 '17 at 12:00
  • Here's an example of a filter expression that suppresses all log messages except those with the tag "ActivityManager", at priority "Info" or above, and all log messages with tag "MyApp", with priority "Debug" or above: `adb logcat ActivityManager:I MyApp:D *:S` from [https://developer.android.com/studio/command-line/logcat.html] – marvatron May 01 '20 at 16:34

1 Answers1

1

Add filters:

adb logcat -v time Foo:V Bar:E *:S

This would allow all verbose (and more severe) logs for the tag Foo, error logs for Bar, and silence everything else.

Regarding grep: if you install something like Git For Windows you'll be able to add grep as a command that can be used from a normal Windows commandline window as well.

Michael
  • 57,169
  • 9
  • 80
  • 125
  • Thanks. In order to do `adb logcat -v time com.example.example:V *:S`, should I register the tag `com.example.example` somewhere? – Basj Dec 14 '17 at 12:04
  • `Foo` corresponds to what you pass as the first argument to `Log.*` in your code (e.g. `Log.d("Foo", "This is a debug log");` – Michael Dec 14 '17 at 12:05
  • Yes, but this won't display crash reasons, does it? (I cannot `Log.d(...)` during crashs, because the app has crashed). – Basj Dec 14 '17 at 12:06
  • The Java stacktraces printed if your app crashes due to an uncaught exception will usually have something like `AndroidRuntime` as the tag. – Michael Dec 14 '17 at 12:11