How to Kill Native Applications from 'Adb Shell'

How to kill native applications from 'adb shell'?

Chirag deleted it, so here it is again:

adb shell ps | grep com.myapp | awk '{print $2}' | xargs adb shell kill

This is to be run outside of the emulator. It is one long Unix command, not four commands with a visual separation. | is syntax, interpreted by your (Ubuntu's) shell, which then pipes the output from adb, grep, etc., into the next. Only ps is executed in the emulator.

Stopping an Android app from console

Edit: Long after I wrote this post and it was accepted as the answer, the am force-stop command was implemented by the Android team, as mentioned in this answer.

Alternatively: Rather than just stopping the app, since you mention wanting a "clean slate" for each test run, you can use adb shell pm clear com.my.app.package, which will stop the app process and clear out all the stored data for that app.


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>

Android ADB stop application command like force-stop for non rooted device

The first way

Needs root


Use kill:

adb shell ps => Will list all running processes on the device and their process ids

adb shell kill <PID> => Instead of <PID> use process id of your application

The second way

In Eclipse open DDMS perspective.

In Devices view you will find all running processes.

Choose the process and click on Stop.

Sample Image

The third way

It will kill only background process of an application.

adb shell am kill [options] <PACKAGE> => Kill all processes associated with (the app's package name). This command kills only processes that are safe to kill and that will not impact the user experience.

Options are:

--user | all | current: Specify user whose processes to kill; all users if not specified.

The fourth way

Needs root


adb shell pm disable <PACKAGE> => Disable the given package or component (written as "package/class").

The fifth way

Note that run-as is only supported for apps that are signed with debug keys.


run-as <package-name> kill <pid>

The sixth way

Introduced in Honeycomb


adb shell am force-stop <PACKAGE> => Force stop everything associated with (the app's package name).

P.S.: I know that the sixth method didn't work for you, but I think that it's important to add this method to the list, so everyone will know it.

Android emulator-5554 offline

In such a case, you can do all of the following in order to be assured that your emulator starts working again :

  1. Go to cmd and type adb kill-server
  2. Go to task manager and find adb in processes. If you find one, right click on it and click on end process tree.
  3. In eclipse, go to Window>Android Virtual Device Manager, click on the AVD you want to launch, click on start and uncheck "Launch From Snapshot" and then click on launch.

That's it! It will take a while and it should resolve your problem.

ADB not responding. You can wait more, or kill adb.exe ... windows 8

Meanwhile the emulator is working again. I cannot definetly say what solved the problem. What It could be a combination of two things:

  • Deleting the hidden ".android" folder under C:\Users...
    (Probably there was some malfunctioning automatically created code)
  • Deleting and recreating the Path variable to the folder with adb.exe ( ...\sdk\platform-tools\;)

Finally it could be a Windows 8 issue which I don't understand.



Related Topics



Leave a reply



Submit