When using the adb Monitor tool to read the Logcat, I like to filter out all everything but what directly affects the app. Trouble is, it's really hard to tell what the PID of your app. It easy enough if the app using Unity, but if it doesn't, It's almost impossible to use to tell.

So is there a ADB command that can tell what PID an app used?


You should be able to run a shell command from adb:

adb shell ps | grep your.app.name

And that will return details about your process. The second number will be the PID of your app. This is if grep is installed. If grep isn't installed, you can just run ps and it will dump all processes to your screen.

You can dump logcat to a file to retroactively look at processes (up to a point)
logcat > /sdcard/logcatDump.txt

However, logcat data is stored in memory so it will all be lost after a reboot.

  • I had the same thought in my mind and in fact wrote the answer until I realized that ps actually shows the PID of running processes. What OP asked here is the PID an app used. ps doesn't care for dead processes AFAIK. – Firelord May 7 '15 at 20:02
  • 1
    Ah, I missed that part. logcat is the only process that I know of that will have that data. It's stored in memory so you can't get it after a reboot. Question is modified to include that. – D. Gibbs May 7 '15 at 20:24

Simply do:

adb.exe shell pidof com.packagename.example

If you want to ensure only one PID is shown try:

adb.exe shell pidof -s com.packagename.example
  • Worked perfectly on Android 9. Seems like an optimal answer. – user598527 Apr 20 '20 at 12:06

Not the answer you're looking for? Browse other questions tagged or ask your own question.