如何从设备上的命令行卸载Android应用程序

时间:2021-03-21 00:11:05

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.

我可以使用adb uninstall 从我的计算机上卸载设备上的应用程序,但我想对实际设备上的脚本执行相同的操作。

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

我也尝试使用am运行android.intent.action.DELETE意图,但它会提示用户进行确认。

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 ?

鉴于设备已植根,是否可以在设备上运行命令以卸载应用程序而无需用户操作/确认?

5 个解决方案

#1


35  

Trying using the pm command:

尝试使用pm命令:

pm uninstall <package_name>

or

pm uninstall -k <package_name>

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

-k标志在删除包后保留数据和缓存目录。

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

我自己没有测试过,但我认为这不会显示警告信息。

#2


8  

adb shell pm uninstall *your.package.name*

adb shell pm uninstall * your.package.name *

Did the trick for me.

对我有把戏。

#3


1  

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

我卸载了一些系统启动器(例如NovaLauncher)失败了在这种情况下我建议使用“禁用”而不是“卸载”:

pm disable <package_name>

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

结果,当你有几个启动器时,你可以从启动器列表中隐藏这个系统启动器(sys app)

#4


1  

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,

尝试运行disable命令,

adb shell pm disable package_name
Package package_name new state: disabled 

#5


1  

To forcefully uninstall the system user apps:

要强制卸载系统用户应用程序:

Use:

adb shell pm uninstall --user 0 <package_name>

#1


35  

Trying using the pm command:

尝试使用pm命令:

pm uninstall <package_name>

or

pm uninstall -k <package_name>

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

-k标志在删除包后保留数据和缓存目录。

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

我自己没有测试过,但我认为这不会显示警告信息。

#2


8  

adb shell pm uninstall *your.package.name*

adb shell pm uninstall * your.package.name *

Did the trick for me.

对我有把戏。

#3


1  

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

我卸载了一些系统启动器(例如NovaLauncher)失败了在这种情况下我建议使用“禁用”而不是“卸载”:

pm disable <package_name>

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

结果,当你有几个启动器时,你可以从启动器列表中隐藏这个系统启动器(sys app)

#4


1  

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,

尝试运行disable命令,

adb shell pm disable package_name
Package package_name new state: disabled 

#5


1  

To forcefully uninstall the system user apps:

要强制卸载系统用户应用程序:

Use:

adb shell pm uninstall --user 0 <package_name>