ADB commands helpful for android automation


ADB (Android Debug Bridge) is a command line tool that let’s us communicate with an emulator or real device.

How to get ADB tool (adb.exe)

This is present under [android sdk -> platform-tools]

Before sending commands, make sure

  • To enable USB debugging on emulator or device  .
  • Device should be connected to computer.

To install Android SDK and enable USB debugging, Refer step 2 & 3 of Appium setup for windows.

ADB commands and their usage

Get device information

Connect device to computer in debug mode, open command prompt and type
adb devices : lists devices connected to computer

If in case, adb devices shows no result, better to use below troubleshooting steps:
type: adb kill-server and key press enter
then, adb start-server and key press enter
then try, adb devices [you should be able to see the device details now]

Note: From the above screenshot, adb devices have any one of the states
[Serial number] [state]
if device is connected, then state shows “device”,
if device is not connected properlly or not responding, then state shows “offline”
If no device connected, then result will be blank

Solution if adb command doesn’t work directly from start –> Run

Navigate to the platform-tools folder under AndroidSDKInstall folder, key press SHIFT and right click then select  “Open command prompt here”, now adb command should work.

Install android apps

this method is applicable irrespective of google play store installed or not on device or emulators

Connect real android device to computer or open android emulator

Prerequisite -> Android SDK should be installed, refer androidSDKInstall

Open command prompt, and type

NOTE: do not use the square brackets while entering .apk file path…

e.g> if xyz.apk is under c:\apps, then you should use

Get android app package and activity

Open the app that you want to get package and activity on device, and should be displayed on screen

Open command prompt, Start -> Run -> cmd, type following commands one by one


From above, orange highlights is the app package and activity
App package: io.selendroid.testapp
App Activity: io.selendroid.testapp.HomeScreenActivity

Copying files to or from device

the pull and push commands let you copy arbitrary directories and files to any location in an emulator/device instance.

To copy a file or directory (and its sub-directories) from the emulator or device, use

To copy a file or directory (and its sub-directories) to the emulator or device, use

In the commands, <local> and <remote> refer to the paths to the target files/directory on your development machine (local) and on the emulator/device instance (remote). For example:

References :

Short link –

Content posted is based on learning or working experience,
Share the post with others if find useful,
Any queries?, leave comments or discuss on our, Thanks!

Leave a Reply

Your email address will not be published. Required fields are marked *