Is there any adb command to enable/disable a system app?
Thanks
Yes. The command is pm disable <package name>
. You must be root in order to do this:
Open shell and get root:
PC> adb shell
shell@hammerhead:/ $ su
List all enabled apps, filter by "calculator":
root@hammerhead:/ # pm list packages -e | grep 'calculator'
package:com.android.calculator2
Disable app:
root@hammerhead:/ # pm disable com.android.calculator2
Package com.android.calculator2 new state: disabled
List all disabled apps:
root@hammerhead:/ # pm list packages -d
package:com.android.calculator2
package:com.google.android.apps.inputmethod.hindi
package:jp.co.omronsoft.iwnnime.ml
package:com.google.android.inputmethod.pinyin
package:com.google.android.inputmethod.korean
package:com.google.earth
root@hammerhead:/ #
Some other things worth noting:
pm enable <package name>
. In fact, this seems to be the only way to re-enable them, in my experience.Manifest
or the like (I'm no Android dev, so I cannot tell).
This should work regardless whether the app is a system app or a third-party app (user installed).
See my answer at Determine the package name of your app to get the package name of the concerned app and use adb shell to execute these commands (requires root access):
adb shell su pm disable PACKAGE # disables the app and hides it in Settings -> Applications pm hide PACKAGE # alternative; for Android Lollipop and above cmd package suspend PACKAGE # alternative; package remains visible in Launcher and Settings app but cannot be used; a feature of Device Administration
PACKAGE
refers to package name of the app
To reinstate the app, replace disable with enable, hide with unhide, and suspend with unsuspend in the said command and execute it with root privilege.
If you've Android KitKat or above and do not have root access, use adb in PC to execute this command:
adb shell pm block PACKAGE # for Android KitKat adb shell pm hide PACKAGE # for Android Lollipop only adb shell pm disable-user PACKAGE # alternative to `pm hide`; for Android Lollipop and above; this works just like disabling an app through Settings app
To reinstate the app:
adb shell pm unblock PACKAGE # for Android KitKat adb shell pm unhide PACKAGE # for Android Lollipop and only if you used `pm hide` earlier adb shell pm enable PACKAGE # for Android Lollipop and above
Changes would take place immediately.
cmd package suspend <package>
worked as expected. Everything else would throw exceptions
pm disable-user
command doesn't hide an app's icon immediately, I have to restart the launcher for changes to take effect.
Commented
Apr 9, 2022 at 15:45
Further to the answer by @eldarerathis, you can disable an app for a specific user. I used this method to remove some apps from a restricted user that weren't listed on the user settings screen. All commands from an adb shell
. Root access is required to make the changes.
First, get the user's id:
$ pm list users
Users:
UserInfo{0:Alice:13} running
UserInfo{11:Bob:18} running
Then
$ pm disable --user 11 com.cyanogenmod.filemanager
Package com.cyanogenmod.filemanager new state: disabled-user
To re-enable
# pm enable --user 11 com.cyanogenmod.filemanager
In this example, Alice can use the file manager but Bob cannot.
You can do a similar thing with hide
instead of disable
. I am not sure which is best, but see this answer. The converse of hide
is unhide
(a reboot may be needed to effect unhide
).
You can list packages with pm list packages --user 11
. Give -e
to list enabled packages or -d
if you want to see disabled ones. There would appear to be no filter for hidden packages.
FWIW: I tried the above on Lollipop with CM 12.1 on an Amazon Fire (KFFOWI).
pm disable-user --user 0 org.lineageos.audiofx
(in adb shell).
Commented
Nov 25, 2023 at 18:15
I wanted to disable the playstore on Vivo phone because my niece always installs multiple gigabytes of games. For some of you this might work, no root is required.
To disable playstore:
$ adb shell pm uninstall --user 0 -k com.android.vending
Success
This uninstalls the app. But there's also a way to restore the app:
$ adb shell pm install-existing com.android.vending
Package com.android.vending installed for user: 0
Of course, playstore is an example. This should work for most system apps. From the PC, you can directly run this, or if you're in an ADB shell, run the command after adb shell
.
You can use adb shell pm list packages
, pipe that to grep to search for the package easily.
Note that this uninstalls the app, the -k flag should keep the data. But in my case all data was purged/deleted. So there might be data loss during the process of uninstallation of system apps.
cmd install-existing com.android.vending
on modern Android. On android 8 pm install-existing
won't work. On old Android versions (4.2) not having cmd you can try pm install -r
to force the reinstallation