This article will introduce how to kill a process/package from ADB command in Android.
1. "adb shell am force-stop"
The following command forcibly stops and changes the com.google.android.youtube
package to a stop state. During this process, the app's process will be terminated.
$ adb shell am force-stop com.google.android.youtube
Note that stop
state means that the app couldn't get any broadcast until it's changed to not stop
state
2. "adb shell kill PACKAGE_NAME"
If you know the PID of a package, then you can terminate it with the kill command.
2.1 How to get the PID of a package with package name
The following command prints the pid of the com.google.android.youtube
package. 5862
is the PID of Youtube.
$ adb shell pidof com.google.android.youtube
5862
Note that If the App is not running, nothing will be output because there are no running processes.
2.2 Killing the process of PID
The following command will kill PID 5862
. But, It will fail due to permission issues if run with an unrooted device.
$ adb shell kill -9 5862
/system/bin/sh: kill: 5862: Operation not permitted
If you root it as follows, the process will end when you enter the command again.
$ adb root
restarting adbd as root
$ adb shell kill -9 5862
To make sure the package is killed, you can check the PID by the following command. Nothing will be outputted if it was killed successfully.
$ adb shell pidof com.google.android.youtube
Related Posts
- How to download and build Android 13, AOSP
- Notification permission request, pop up notification in Android 13
- Resolve `Access blocked: ComponentInfo` error on Android 13
- Fix error "android gradle plugin requires java 11 to run. you are currently using java 1.8."
- Android - Vibration, Vibrator, VibrationEffect example
- How to get phone number in Android
- How to create Bugreports and Logcat with ADB in Android
- Clear application user data with ADB in Android
- How to disable/enable apps with ADB in Android
- How to find PID of a package with adb in Android
- How to grant/revoke permissions with adb in Android
- How to install an apk(app) with adb in Android
- How to kill a process/package from ADB in Android
- How to transfer files using adb push/pull command in Android
- How to capture the screen from adb in Android
- How to uninstall/install system apps from adb in Android
- How to change Settings values from adb in Android
- How to Factory reset with ADB in Android
- How to get logcat from ADB command in Android
- How to capture Heap Dump from app with ADB in Android
- How to force stop an app with adb in Android
- How to start/stop a service from adb in Android
- How to send/broadcast an intent from adb command in Android
- How to start an activity from adb in Android
- How to generate input from adb in Android
- How to check SQLite DB table in Android Studio
- How to get memory info and thread list from adb in Android
- Android - Uri, Scheme and SSP(Scheme Specific Part)
- How to parse a xml file with XmlResourceParser in Android
- Android - Signing an apk with Platfom key
- How to fix "Cleartext HTTP ... not permitted" for Android development
- How to fix "kvm permission denied" for Android Emulator
- Using ADB over Wifi for Android development