< Back to all hacks

#23 Android Debloat (No Root)

Debloat
Problem
Stock Android uses ~450 MB RAM. No room for the gateway.
Solution
pm uninstall -k --user 0 for 31 packages in 3 waves. PERMANENT on Android 6 (no pm install-existing).
Lesson
NEVER remove com.motorola.android.providers.settings — causes permanent boot loop.

Context

Stock Android 6.0 on the Moto E2 uses approximately 450 MB of its 1 GB RAM before any third-party app runs. The gateway needs ~155 MB, Termux needs ~48 MB, and the OS floor (system_server + zygote + launcher) takes ~165 MB. That is already 368 MB with zero bloatware, leaving no margin. Every megabyte freed from stock packages directly determines whether the gateway can run without being killed by the low-memory killer.

Android provides pm uninstall -k --user 0 which removes a package for user 0 without needing root. The -k flag keeps the package data on disk (in case you want to reinstall). On Android 7+, the reverse command pm install-existing restores a user-uninstalled system package. But on Android 6, pm install-existing does not exist. This means every pm uninstall -k --user 0 on this phone is PERMANENT — the only way to restore the package is a factory reset.

This permanence is both the danger and the advantage. Dangerous because one wrong removal can brick the phone. Advantageous because the packages stay gone across reboots, unlike pm disable (which requires root and can be undone by system updates).

Implementation

Packages were removed in 3 waves, rebooting between each wave to verify the phone still boots and functions. This conservative approach catches boot-loop-causing removals before too many packages are gone.

# Wave 1 — 12 packages (safe, obvious bloat)
adb shell pm uninstall -k --user 0 com.google.android.inputmethod.latin
adb shell pm uninstall -k --user 0 com.google.android.setupwizard
adb shell pm uninstall -k --user 0 com.android.calculator2
adb shell pm uninstall -k --user 0 com.android.dialer
adb shell pm uninstall -k --user 0 com.android.bluetooth
adb shell pm uninstall -k --user 0 com.android.email
adb shell pm uninstall -k --user 0 com.android.exchange2
adb shell pm uninstall -k --user 0 com.android.music
adb shell pm uninstall -k --user 0 com.android.calendar
adb shell pm uninstall -k --user 0 com.google.android.talk
adb shell pm uninstall -k --user 0 com.google.android.videos
adb shell pm uninstall -k --user 0 com.google.android.apps.plus
# Wave 2 — 16 packages (telephony, media, downloads)
adb shell pm uninstall -k --user 0 com.android.providers.calendar
adb shell pm uninstall -k --user 0 com.android.browser
adb shell pm uninstall -k --user 0 com.android.gallery3d
adb shell pm uninstall -k --user 0 com.android.camera2
adb shell pm uninstall -k --user 0 com.android.stk
adb shell pm uninstall -k --user 0 com.google.android.apps.docs
adb shell pm uninstall -k --user 0 com.google.android.apps.maps
adb shell pm uninstall -k --user 0 com.google.android.apps.photos
adb shell pm uninstall -k --user 0 com.google.android.apps.books
adb shell pm uninstall -k --user 0 com.google.android.apps.magazines
adb shell pm uninstall -k --user 0 com.google.android.gm
adb shell pm uninstall -k --user 0 com.google.android.music
adb shell pm uninstall -k --user 0 com.google.android.youtube
adb shell pm uninstall -k --user 0 com.google.android.googlequicksearchbox
adb shell pm uninstall -k --user 0 com.motorola.help
adb shell pm uninstall -k --user 0 com.motorola.migrate
# Wave 3 — 3 packages (final, more aggressive)
adb shell pm uninstall -k --user 0 com.android.chrome
adb shell pm uninstall -k --user 0 com.google.android.gsf
adb shell pm uninstall -k --user 0 com.google.android.location.fused

Verification

# Count remaining enabled packages:
adb shell pm list packages -e | wc -l
# Expected: ~33 (down from 64+)

# Check total uninstalled:
adb shell pm list packages -u | wc -l
# Shows all packages including uninstalled — compare with -e count

# Verify the phone still boots:
adb reboot
# Wait for boot animation to finish, then:
adb shell getprop sys.boot_completed
# 1

# Check RAM freed:
adb shell cat /proc/meminfo | grep MemAvailable
# Should show ~100 MB more than before debloat

Gotchas

  • NEVER uninstall com.motorola.android.providers.settings. This causes a permanent boot loop. The phone gets stuck at the Motorola logo and the only fix is a factory reset via recovery mode (volume down + power)
  • NEVER uninstall ALL launchers. Android requires at least one app with the HOME intent filter. Without one, the phone hangs at the boot animation forever. Keep at least one launcher (PocketClaw Launcher or Trebuchet)
  • Every removal is PERMANENT on Android 6. There is no pm install-existing command. The only way to restore an uninstalled system package is a full factory reset, which wipes all data
  • Two packages resist removal: com.google.android.gms (Google Play Services) and com.motorola.ccc.devicemanagement (Device Policy Manager). Both return "Failure" from pm uninstall. These require root to disable (see Hack #26)
  • Disabling com.android.defcontainer (DefaultContainerService) breaks adb install. If you need to install APKs later, re-enable it first: adb shell pm enable com.android.defcontainer
  • Remove in small waves with reboots between them. If you remove 31 packages at once and the phone boot-loops, you have no way to know which package caused it
  • The -k flag (keep data) does not help on Android 6 — the package cannot be reinstalled regardless. The flag is harmless but provides no safety net

Result

MetricStock AndroidAfter 31 Removals
Enabled packages64+~33
Background processes40+~25
Available RAM~180 MB~280 MB
RAM freedN/A~100 MB
ReversibleN/ANo (factory reset only)
Resists removalN/A2 (GMS, Device Policy)