问题
I'm new to Android Studio, using latest version, and trying to code a basic calculator app.
For some reason, my logcat is full of
2021-01-11 14:38:35.288 6938-6938/? W/cmd: Can't find service car_service
This is really annoying for debugging.
How can I get rid of it ?
回答1:
I'll change my comment to an answer, seeing as though it actually helped:
click on logcat at the bottom of android studio, then (i'm assuming) yours will show no filters
, change that dropdown to show only selected application
. Not really much I can explain here, except for the fact that if you don't have it setup like this, logcat will print out things which are irrelevant to your app in addition to the logs from your own application
回答2:
Additionally, to all future readers... Android Logcat is quite verbose, especially on Emulators (where a lot of things throw errors/warnings) but not limited to; Samsung devices spit more log than useful information (And they are not alone), so a way to keep it under some control, is to (ab)use the Regex feature of the logcat filter in Android Studio.
E.g.:
Create a new LogCat Filter and filter by Tag, Message, or Package (or all 3 like I do):
This is an example I use in "Message":
^((?!EGL_emulation|eglCodecCommon|OpenGLRenderer|MicroDetectionWorker|MicroDetector|KeyguardClockSwitch|adbd|OIMC|base.apk|wakelock|com.google.android.apps.youtube.music).)*$
You can edit/add more to these and/or repeat it for LogTag, Message, or Package Name.
It's mostly trial and error. (some devices spit different spam via logcat).
My Log Tag filter for this "very filtered app" output is:
^((?!vendor.qti.bluetooth|AppDynamics|KeyguardUpdateMonitor|BatteryExternalStatsWorker|BatteryStatsService|tftp_server|Clock|libc|OnePlusSmartBoostManager|OnePlus|ANDR-RAMBOOST_SERVER|BoundBrokerSvc|DateView|BatteryStatsHelper|BoundBrokerSvc|RenderThread|FacsCacheGmsModule|DownloadProgressMonitor|MendelPackageState|GoogleTagManager|SELinux|Volley|ConfigFileUtils|NetRec|YouTubeMusic|GEL_DELAYED_EVENT_DEBUG|gms|AsyncOperation|angh|ContentCacheSuperpacksManager|SuperpacksManager|AwarenessClientProvider|WakeLock|GLSUser|perfetto|cmd|chatty|Binder|Fitness|Icing|GnssHAL_GnssInterface).)*$
and for Package Name:
^((?!EGL_emulation|eglCodecCommon|OpenGLRenderer|MicroDetectionWorker|MicroDetector|KeyguardClockSwitch|adbd|OIMC|base.apk|wakelock|com.google.android.apps.youtube.music).)*$
Of course your mileage will vary in what you need, and sometimes I edit these and add/remove some parts as I see fit.
This is how it looks:
来源:https://stackoverflow.com/questions/65667969/how-to-filter-logcat-to-remove-irrelevant-statements