Android Debug Bridge (Adb) Command Line Tools

Siddhi agrawal
Tech x Talent
Published in
3 min readMar 21, 2023

What is adb?- Adb is a command line tool that allows to communicate with a device. The device can either be a emulator instance or physical connected Android- powered device.

Steps to connect physical Android- powered device to your local machine:-

  1. Enable “Developer Options” on your phone. You can refer to the following link for assistance: https://www.javatpoint.com/how-to-enable-or-disable-developer-options-on-android
  2. Once you have activated “Developer Options” , enable USB Debugging.

Settings > Developer Options > USB debugging

Now your device is all set to connect to your PC.

3. Connect your phone and PC using a USB cable.

4. Install any application that enables users to share and control iOS and android screens on desktops. e.g — Vysor

Some common Adb commands:-

  1. adb devices — Show Connected Devices
  2. adb -s <device> <command> — Direct ADB command to specific device in a multi-device setting. e.g:-
>adb devices // This shows 2 devices are currently connected

List of devices attached
emulator-5554 device
02157df2d1faeb33 device

>adb -s emulator-5554 shell //Use the -s option followed by a device name to
select on which device the adb command should
run

3. adb -d <command> — In a multi-device setting, redirects to the only USB connected device.

4. adb -e <command> — In a multi-device setting, redirects to the only running emulator.

5. adb reboot — This command helps to reboot the device. It is useful in issues like when your smartphone becomes unresponsive.

6. adb help — List all the commands

7. adb kill-server — This Command is used to kill an adb server if it is running

8. adb start-server — To start the adb server

9. adb install commands

adb install [path/to/file.apk] — Push an Android application to an emulator/device

adb install -r [path/to/file.apk] — To replace an existing application . It is to reinstall an existing app, keeping its data intact.

adb install -t [path/to/file.apk] — Allow installation of test packages

adb install -g [path/to/file.apk] — Grant all permissions listed in the app manifest

adb install — fastdeploy [path/to/file.apk] — Quickly update an installed package by only updating the parts of the APK that changed

10. adb push [path/to/Source] [path/to/Destination] -

This command is use to send files to your android device from your PC.

11. adb pull [FileLocation] [DestinationPath] — This ADB command lets you pull a file from your Android device so that it appears on your connected laptop or computer.

Note — To Disconnect USB device from adb , you can use adb disconnect or simply turn off usb debugging under developer options

How to open React native debug menu on device:-

  1. On Emulator — Press Command + M
  2. On USB connected device- adb shell input keyevent 82

Note: adb reverse tcp:8081 tcp:8081 — This command allows you to expose a port on your Android device to a port on your computer.

In the example above you are going to expose tcp port 8081 on the phone via port 8081 on your computer.

So even if after connecting your device to PC , you are not able to start the server, you might need to use the above command.

Conclusion:

Let’s write a set of steps to start development server on USB connected device-

  • Start USB debugging on device and connect it to PC using a USB cable.
  • Open applications like Vysor on PC and select the device from there.
  • Open Terminal and type adb devices . Ensure your device appears in list of attached devices.
  • Next lets install apk file to our device . Use — adb install -t [path/to/file.apk]
  • Go to your project directory and start the development server. Use react-native start

If development server doesn’t start , try using adb reverse tcp:8081 tcp:8081 command , and restart the development server.

--

--