How to uninstall an android app from command line

2019-01-21 14:42发布

问题:

I can uninstall an app on the device from my computer using adb uninstall <package_name>, but I'd like to do the same with a script on the actual device.

I've also tried running an android.intent.action.DELETE intent using am but it prompts the user for confirmation.

Given that the device is rooted, is it possible to run a command on the device to uninstall an app without requiring user action/confirmation ?

回答1:

Trying using the pm command:

pm uninstall <package_name>

or

pm uninstall -k <package_name>

The -k flag keeps the data and cache directories after the package is removed.

I haven't tested this myself, but I don't think this should show a warning message.



回答2:

adb shell pm uninstall *your.package.name*

Did the trick for me.



回答3:

To forcefully uninstall the system user apps:

Use:

adb shell pm uninstall --user 0 <package_name>


回答4:

I had fail on uninstall some system launchers (for example NovaLauncher) In this case I recommend to use "disable" instead "uninstall":

pm disable <package_name>

In result you hide this system launcher (sys app) from list of launchers when you have a few launchers



回答5:

Some Apps can't be uninstalled,so below command gives the error:

adb shell pm uninstall package_name
Failure [DELETE_FAILED_INTERNAL_ERROR]  

Try to run disable command instead,

adb shell pm disable package_name
Package package_name new state: disabled