24

Have to mention this to avoid possible confusion, this question is not duplicate. This question is specific to using adb to uninstall a package. There are several similar questions but are all different from this one, as they're focused on removing an application by any means.

Please do not provide answers using "rm" command to delete the package files. Also, answers related to malformed package names, or trailing carriage returns. I think they're pretty much all covered in all the other questions.

I had pm uninstall functionality but after ROM upgrade. Some things won't uninstall anymore. For example the following two system apps (which I removed under previous ROM, significantly improving overall performance):
/system/priv-app/SecurityCenter/SecurityCenter.apk=com.miui.securitycenter
/system/app/Updater/Updater.apk=com.android.updater

Now I get an error trying to pm uninstall them: Failure [DELETE_FAILED_INTERNAL_ERROR]

But other system apps (which won't uninstall through regular android interface) do uninstall via pm uninstall command. Example:
/system/priv-app/Browser/Browser.apk=com.android.browser

So both are system apps, what could be the difference between them?

For reference, I upgraded from MIUI 8.1.6.0 to 8.5.3.0, and re-installed TWRP and SuperSU. This question is not specific to my ROM, as I see other people are in the same situation. But I seem to have an advantage being able to be able to uninstall some system apps. And am willing to contribute, to find a solution for everyone, to uninstall any app.

I tried: mount -o rw,remount /system
but that didn't solve it.

Please help out with any ideas along the way. Thanks!


Update 1 - Confirming steps to avoid intermittent issues
* Wiped all partitions in TWRP
* Installed Latest ROM (MIUI 8.5.3.0)
* Went back to TWRP, wiped only /Data
* Restored /Data from backed up version of the ROM that came with device (MIUI 8.1.6.0)
* Now after I boot into OS, ROM shows as latest (MIUI 8.5.3.0) in settings

Now I am able to pm uninstall every app I've tried. Even the most resilient: Google APP, Updater, Security.

This Frankenstein.. err I mean hybrid ROM works fine so far, and I've already removed many system packages, making the phone (Redmi 3S+) visibly faster. But I would still like to pinpoint what was causing this to make it into Generic Solution. So, if it ain't broke I'm willing break it, so next time it breaks we will know what's causing it and how to fix it.

Update 2 -
* Wiped all partitions and restored all partitions from Original ROM.
* Restored to factory settings (using TWRP)
* and after booting into ROM, went back to TWRP and made another backup
* Using same scenario as in Update 1 above, with only exception of using /Data from here. pm uninstall does not work.

Any thoughts on the differences between the two /Data partitions I should be focusing on?

6
  • 2
    AFAIK pm uninstall cannot be used with system apps. As it's not clear whether you really want to uninstall or simply to hide an app (you mentioned pm disable), could pm hide be what you're really after?
    – Izzy
    Commented Jul 16, 2017 at 23:24
  • @Izzy Yes it can. That's what I'm saying above, I just edited/made it a bit clearer. I want to pm uninstall but what I meant was, before upgrading, I could do both, uninstall and disable on System apps, even wrote nice scripts to take care of everything after upgrade.
    – Emil
    Commented Jul 17, 2017 at 5:34
  • I have never succeeded with pm uninstall on system apps. But I have a guess: Is your previous ROM an "engineering" build? I suppose it works with an eng build (aka dev build).
    – iBug
    Commented Jul 17, 2017 at 5:37
  • @iBug no, actually previous ROM was the one that this phone came with. The new ROM is also an official upgrade from manufacturer's site.
    – Emil
    Commented Jul 17, 2017 at 5:40
  • 1
    @Firelord My MIUI Optiomization setting was already off. device_owner.xml is absent. device_policies.xml just has these lines: <?xml version='1.0' encoding='utf-8' standalone='yes' ?> <policies setup-complete="true"> <active-password -stuff here- /> </policies>
    – Emil
    Commented Jul 19, 2017 at 7:34

2 Answers 2

27

I succeded adding the -k and --user options to the pm command, e.g.:

pm uninstall -k --user 0 com.android.service

The command was issued as root, no need to remount /system as rw. Android on the phone is 6.0 and the package is a system app. Without the extra option I get the error:

Failure [DELETE_FAILED_INTERNAL_ERROR]
3
  • 1
    Thank you. For anyone else reading, some guides have a single dash in front of the user, which was causing the error for me.
    – TrojanName
    Commented Aug 24, 2018 at 21:08
  • 4
    Note: -k is not needed. Guides on the internet do copy-paste blindly. -k is to keep app data intact. 9/10 if you are removing bloat, you should not care for preserving the app's data. No need for that flag.
    – Firelord
    Commented Apr 25, 2021 at 9:53
  • for me it worked using: adb shell cmd package uninstall -k --user 0 com.android.service
    – Kreshnik
    Commented Jul 13, 2022 at 19:00
15

Also works without -k (keep user settings) option:

pm uninstall --user 0 com.android.service

and without opening adb shell:

adb uninstall --user 0 com.android.service
1
  • 3
    upgraded from miui 10 to miui 11. but for few system/priv-app these cammands fail. eg for com.miui.calculator
    – srv_sud
    Commented Jan 24, 2020 at 8:48

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .