Search code examples
androidapkadb

Difference between adb uninstall and adb uninstall --user 0


I recently discovered that I can remove the factory version of chrome from a device with:

adb uninstall --user 0 com.android.chrome

However, after the app is uninstalled, I can no longer reinstall chrome with:

adb install-multiple chrome-split-apk-dir

The command does not fail, however chrome is not present on the device after the install completes:

$ pm list packages | grep chrome
1

However I can install chrome by using the --user 0 option again:

adb install-multiple --user 0 chrome-split-apk-dir

My question(s):

  • Why can I uninstall factory chrome version --user 0? I thought that if you don't include the user, the app will be uninstalled from all users by default, including --user 0, so the behaviour shouldn't be different.
  • Why can I now only reinstall chrome by using --user 0 ?

Thanks!


Solution

  • --user specifies the user to run as, not the user its uninstalled from. 0 is root in Linux. You're telling it to run the uninstall command as root, which obviously has heightened privileges and can do it. A normal user doesn't and can't. The same applies for install.