views:

50

answers:

2

Is it possible to stop an Android app from the console? Something like:

adb stop com.my.app.package

It would speed up our testing process so much. Right now we uninstall/install the app each time to make sure the manual test cases start with a clean state.

A: 

In eclipse go to the DDMS perspective and in the devices tab click the process you want to kill under the device you want to kill it on. You then just need to press the stop button and it should kill the process.

I'm not sure how you'd do this from the command line tool but there must be a way. Maybe you do it through the adb shell...

matto1990
+1  A: 

If you're on Linux:
adb shell ps | grep com.myapp | awk '{print $2}' | xargs adb shell kill

That will only work for devices/emulators where you have root immediately upon running a shell. That can probably be refined slightly to call su beforehand.

Otherwise, you can do (manually, or I suppose scripted):
pc $ adb -d shell
android $ su
android # ps
android # kill <process id from ps output>

Christopher
Couldn't get it to work (permission denied both for kill and su), but +1 for showing me I can do lots more than I thought with adb.
hgpc
Ah, sounds like you don't have a rooted device. It definitely works on the emulator at least! :)
Christopher
Maybe you have to remount the partition read-write and run adb as root: adb remount; adb root # that's just a stupid guess thought
Rorist