Alt Tag

Android Debug Bridge (adb)

Android Debug Bridge (adb) is a versatile command-line tool that lets you communicate with a device. The adb command facilitates a variety of device actions, such as installing and debugging apps. adb provides access to a Unix shell that you can use to run a variety of commands on a device. It is a client-server program that includes three components:

  • A client, which sends commands. The client runs on your development machine. You can invoke a client from a command-line terminal by issuing an adb command.
  • A daemon (adbd), which runs commands on a device. The daemon runs as a background process on each device.
  • A server, which manages communication between the client and the daemon. The server runs as a background process on your development machine.

Setup Guide

Setting up adb

Windows

  1. Obtain the adb Platform Tools from the official Android developer website.
  2. Unzip the platform-tools-latest-windows.zip file and navigate to the extracted folder.
  3. Within the folder, access the Command Prompt by typing cmd in the File Explorer’s address bar and pressing Enter.

Direct navigation to the folder is required unless you have added the directory to your Environment Variables, which is detailed later in this guide.

Android

  • Enable Developer Options and USB/Wireless debugging:
    1. Navigate to Settings > About phone.
    2. Tap Build number seven times until the message “You are now a developer!” appears.
    3. Access Developer Options.
    4. Enable USB debugging or Wireless debugging, depending on your preference.
USB debugging
  1. Execute adb devices in the Command Prompt.
  2. If prompted on your phone, select “Always allow from this computer” and confirm.
Wireless debugging
  1. In Developer Options, select Wireless debugging and choose Pair with a code.
  2. Execute adb pair <ip-address>:<port> using the provided IP address and port.
  3. Enter the pairing code when prompted in the terminal.

For multiple devices connected, use the device serial number with commands, e.g. adb -s <serial-number> <command>.

Android TV

  1. Enable Developer Options and USB debugging.
  2. Locate the option according to your TV manufacturer’s settings.
  3. Connect via adb connect <ip-address>, using the IP address from the TV’s Wi-Fi settings.

Storage Backup & Restore

adb provides a way to back up and restore internal storage and SD card data directly from a computer. This can be useful for transferring data between devices. To do so:

  1. Open Command Prompt and run adb devices to list connected devices.
  2. Use adb pull -a /sdcard <destination-path> to copy the entire internal storage. The -a flag preserves file attributes.
  3. Set up adb on the target device and connect it to your computer.
  4. Push the data using adb push <source-folder>\. /sdcard, e.g. adb push "D:\My phone\sdcard\." /sdcard.
  5. Upon completion of the necessary adb operations, execute the command adb kill-server. This will terminate the adb service.

Installing APK Files

adb also allows you to install APK files directly onto your Android device from a computer. To get started:

  1. Use reputable sources like APKMirror, UpToDown, or APKPure to download APK files.
  2. With the device connected, execute adb install <apk-filename> from the directory containing adb.exe and the APK file. You may also specify the full path to the APK file if it is located in a different directory.

Uninstalling & reinstalling OEM apps

Many Android devices come with pre-installed (OEM) apps that cannot be uninstalled through the normal settings menu. These apps can take up storage and system resources. While they cannot always be completely removed without root access, adb allows you to disable or uninstall them for the current user (without permanently deleting them from the system).

Uninstalling

Uninstalling certain system apps can be risky and may lead to crashes or even render the device unusable. Some apps rely on others to function properly, so carefully consider the potential consequences before removing any system applications

To uninstall apps:

  1. Type adb shell and hit Enter.
  2. Then, run:
    pm list packages | grep 'OEM name'
  3. This will bring up a list of all the OEM apps. You can alternatively use App Inspector to view apps and their related info, including package name.
  4. To remove a package, run:
    pm uninstall -k --user 0 <name-of-package>

Options are:

  • -k: keep the data and cache directories around after package removal.
  • --user: remove the app from the given user.

Reinstalling

To reinstall uninstalled apps back:

  1. Run:
    pm install-existing <name-of-package>

This works because the apps aren't permanently uninstalled (that requires root access), and only are uninstalled for the main user, 0, as given by the parameter --user. Therefore, you'll still receive OTA updates through this method. This method can be used for any app.

Setting Environment Variables

Making an environment variable will make adb accessible from any location in the terminal. To make an environment variable for adb:

  1. In the Start Menu, search for Edit the system environment variables.
  2. Open Edit the system environment variables and navigate to Environment Variables....
  3. Under System variables, select the Path variable and click Edit.
  4. Add the directory containing adb.exe using the New or Browse options.
  5. Confirm all dialogs with Ok.

For further assistance or advanced configurations, consult the official Android Debug Bridge documentation.

Also, check out the FMHY Discord to learn, share and connect with the great developers.

Alt Tag

Edit
Pub: 29 May 2024 16:43 UTC
Edit: 24 Feb 2025 12:07 UTC
Views: 2277
Auto Theme: Dark