Reputation: 63546
I try to run
adb shell kill 5539
where 5539
is a process id found when running adb shell ps
, but I get
/system/bin/sh: kill: 5539: Operation not permitted
How can I rectify my permissions?
This is the only adb documentation on kill:
kill [options]
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.
Upvotes: 16
Views: 28250
Reputation: 1020
I had the same problem with real device and I couldn't get root access.
When I run the command: adb root
I got the following error: adbd cannot run as root in production builds
I solved it by using the emulator. The emulator allows you to get root access.
Run your app on the emulator and then run these commands:
adb root
adb shell ps | grep com.your.app_package | awk '{print $2}' | xargs adb shell kill
The second command finds the PID
of the app and kills it, if you don't know the PID
.
or you can use your command:
adb shell kill <PID>
Upvotes: 1
Reputation: 570
My methods:
Without root
adb shell am force-stop <package name>
I don't know how to do it with PID, kill <PID>
and kill -9 <PID>
don't work in my case
With root
I have also installed BusyBox to get more UNIX tools on my device
adb shell "su -c 'kill $(pidof <package name>)'"
or
adb shell "su -c 'kill <PID>'"
Upvotes: 23
Reputation: 63546
I can only access the database of my emulator, not my device. Start the emulator using emulator -avd <device name>
where you can find the device name by running android avd
.
Upvotes: 0
Reputation: 386
You need to restart adb as root
This will give you permissions to kill the process.
$ adb root
$ adb shell kill 5539
Upvotes: 12