Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to "force stop" an application I am debugging using adb in terminal?

I am developing an app, and for debugging certain actions on first installation I found that using the terminal command:

./adb uninstall <package-name>

was a lot fast than navigating to settings, apps, waiting for the apps to load, finding your app, and uninstalling it. I would strongly recommend it for anyone that doesn't already use it for debugging.

Now I am trying to work on the force close part of my app, and I can't find anywhere in the android doc, instructions on how to force close an app by adb command.

Is it possible?

like image 901
NotACleverMan Avatar asked Jul 08 '11 14:07

NotACleverMan


3 Answers

am force-stop YOUR.PACKAGE.NAME

This command worked for me. Hope so this will help you as well.

like image 180
Arief Widiyanto Avatar answered Oct 17 '22 18:10

Arief Widiyanto


You can use adb shell kill to kill the process, but first you need to find the process id. To do this you can use adb shell ps and parse the output. Here is a sample (assuming your development PC is Unix):

adb shell kill $(adb shell ps | grep YOUR.PACKAGE.NAME | awk '{ print $2 }')
like image 43
Michael Smith Avatar answered Oct 17 '22 19:10

Michael Smith


You can close one by his pid using

adb shell kill <PID>

but I'm not sure of doing it with a package name.

like image 43
matsjoe Avatar answered Oct 17 '22 19:10

matsjoe