8

I am able to start native applications using am start -a action -n packagename/activity. How can I kill/stop a native application from adb shell?

ThomasW
  • 16,981
  • 4
  • 79
  • 106
RanjitRock
  • 1,421
  • 5
  • 20
  • 36
  • 1
    possible duplicate of [Stopping an Android app from console](http://stackoverflow.com/questions/3117095/stopping-an-android-app-from-console) – janot Oct 21 '14 at 11:46

4 Answers4

34
adb shell am force-stop packagename
Tema
  • 4,100
  • 2
  • 22
  • 12
10

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.

Julian Fondren
  • 5,459
  • 17
  • 29
6

Another way to kill your app is to send your app to backround (using home button) and call:

adb shell am kill com.your.package

It works not on all of my devices, however, on devices where it works it behaves the same way as if the app was killed in background due to lack of resources and this state is often handy to test different aspects of your process recreation.

For example, if you have Broadcast Receivers registered in Manifest, they will still start without restarting your app manually, comparing to force stop that you can achieve using:

adb shell am force-stop com.your.package
Gaket
  • 6,533
  • 2
  • 37
  • 67
1

Please try the below command in adb shell.

adb shell kill <PID>
Chirag
  • 56,621
  • 29
  • 151
  • 198
  • 1
    @user774217, That's not to be run in android's shell. See that it begins with `adb shell`? Try it in Ubuntu. – Julian Fondren Feb 16 '12 at 06:53
  • Julian Fondren is right . please try it in your ubantu terminal . – Chirag Feb 16 '12 at 06:54
  • This kills the process but does not guarantee the app is closed and gone. For example trying this on skype would make the app just restart instantly (try it once you are logged into skype). – MindWire Apr 04 '12 at 18:48