Monday, August 26, 2019

ADB Commands - Must Know for Appium | Mobile Automation

In this Post we will learn about must know ADB commands for appium and how we can use adb commands from command line prompt.  Because these are basic commands automation engineer should know. We will learn below adb commands:


  1. Adb start-server
  2. Adb kill-server
  3. Adb version
  4. Adb devices
  5. Adb install
  6. Adb logcat
ADB : ADB stands for Android Debug Bridge. It is a command line tool that lets us communicate with an Android device or an Emulator. It is a client-server program that includes three components:
  • A client, which runs on our machine. We can invoke a client by issuing an adb command.
  • A daemon, which runs as a background process on each emulator or device instance. It by default runs on port number 5037
  • A server, which runs as a background process on our machine. It manages communication between the client and the adb daemon running on an emulator or device.

1. Adb start-server: This command checks whether the adb server is running and starts it, if not running. sometimes adb server not started or killed. that time we should use this command.


 command:  adb start-server




2. adb kill-server : This command terminates the adb server.  in some cases like you are not able to find your device is not listing or issues with adb server. we should use this command to kill the existing instance and again use adb start-server command to start freshly.

Command: adb kill-server




3. adb version: This command prints the adb version number


command: adb version



4. adb devices: This command prints status information of all the attached devices. when you to give the udid or device name in your appium script, you should execute this command to know the device name and udid.

Command: adb devices




This displays the information in the format:
Serial Number   State
6a2ed0b            device

Serial Number: A string created by adb to uniquely identify an emulator/device
State: The connection state of the instance. It can be offline, device, no device
  • Offline : The device is not connected or not responding
  • device : The device is connected to adb server
  • no device : There is no device connected to adb server
5. Adb install: This command will install the apk file to attached device / emulator. whenver you want to install the apk file from your computer, connect your device and you can use this command to install apk by giving the path.

Command: adb install <local_path_to_apk>




Note: Emulator should be up & running before firing adb install command. In the above screen shot emulator-5554 is displayed with device status, it means it is up & running.
Note: the path of my APK file is D:\ ApiDemos-debug.apk


6. adb logcat: This command will print the logs data to the screen for the purposes of bug reporting. We can also store these logs into local file using below command:

Command: adb logcat > <local_path_to_text_file>



A log file will be created at the given location:



No comments:

Post a Comment

If any suggestions or issue, please provide