Removing bloatware from Android phones

Most Android phones come with many preinstalled apps that you might not ever use, but they do take up valuable space and clutter the interface. If you try to uninstall them the way you would any other apps you will find that it's not possible. So is there a way to get rid of them?

It's actually not too complicted to uninstall them using the right tool which are available for every major operating system.

Keep in mind that while you can reinstall the packages if you change your mind later, but uninstalling them will wipe out all the application data and might sometimes interfere with correct functionning of other applications. Please make sure that you back up all your important data before starting to play around

To install the necessary tools on Linux you can use the command:

sudo apt update && sudo apt install android-tools-adb android-tools-fastboot

On Windows and MacOS you can use brew or choco package managers to install the tools.
Windows:

choco install adb

MacOS:

brew install android-platform-tools

Now that you have the tools on your computer you need to enable USB debugging on your phone. First, go to Settings -> About Phone and tap on the build number seven times until you unlock the developer mode. Then go to Settings -> System -> Advanced -> Developer Options and enable USB debugging.

When you connect your phone to the PC via USB you should get a notification popup to confirm the incoming debugging connection from your PC. Your need to confirm it in order to proceed.

To verify that the device is connected you can use the command:

adb devices

Now your can list all the packages installed for your user.

adb shell pm list packages --user 0

You can use the grep command to filter only specific types of packages, for example:

adb shell pm list packages --user 0 | grep google

This would look for google pacakges. On Xiaomi phones you can search for 'miui' which should return their preinstalled packages.
If you would like to remove the package for a user (Gmail app in this case):

adb shell pm uninstall -k --user 0 com.google.android.gm

To find out the name of the package you can go the the play store page of an app and look at the URL. You should find the name of the package in the id parameter. This would be the link to the Gmail app:

https://play.google.com/store/apps/details?id=com.google.android.gm

To reinstall the app:

adb shell cmd package install-existing com.google.android.gm

You can also choose to only disable the apple for the user:

adb shell pm disable-user --user 0 com.google.android.gm

To enable:

adb shell pm enable --user 0 com.google.android.gm