Second Attempt: Again it displayed two device but this time the Emulator is showing as Offline state, as I switched it off.

Third Attempt: In the last attempt it is not displaying anything, as I detached the attached device and shutdown the running Emulator on the machine.

How to install an apk file to an emulator/read android device?

Command Syntax:adb install <local_path_to_apk>

This command will install the apk file to attached device / emulatorNote: 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: I got one Amazon APK file placed at C:\Apps\Amazon.

Once done, notice that the Amazon app will display in the Emulator screen.

How to capture logs of android device?

Command Syntax: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 Syntax:adb logcat > <local_path_to_text_file>

How to start and terminate adb server?

Command Syntax to Start Server:adb start-server This command checks whether the adb server is running and starts it, if not running.

How to starts a remote shell in the target emulator/device instance?

Command Syntax: adb shell

ADB provides a Unix shell that can be used to run a variety of commands on an emulator or connected device. The command binaries are stored in the file system of the emulator or device. The following commands can be executed on shell:

Command Syntax:pm list packages –f Using pm (package manager tool) we can perform actions and queries on app packages installed on device. E.g. we are listing all packages with path of their associated file.Note: Here pm is a tool and list package is a command and –f is an option to list path of file associated with package.

The above command can also be utilized to print the package of installed apps. E.g. Android browser’s app package can also be printed with this which is installed on the device.

Command Syntax:pm uninstall <app Package Name> This can be used to uninstall an app using pm tool as per above mentioned command.Step 1: To get the package for Amazon appStep 2: Uninstall Amazon PackageStep 3: Again to get the package for Amazon app, this time it will not displayed anything, as Amazon app is now uninstalled from the device, please refer the below screenshot.

How to pull a file (.txt/.pdf/.jpg/.apk ) from a device/emulator to local machine?

How to redirect adb command to a specific device?

If multiple emulators are running and/or multiple devices are attached and if perform adb shell command. This command returns an error if more than one devices are attached. Refer the below screenshot for Step 2.

-d, -e, or -s options can be used to specify the target device to which the command should be directed.Command Syntax:adb -s <deviceName> <command>

Author: Amit Jain

My name is Amit Jain. I work as a manual and automation tester both as Individual Contributor role. I have total 8 years of testing experience. I worked for Ecommerce,Retail domain projects in mobile and web both. I work for an IT company in Noida. I feel it is very important for every tester to look more and more inside system to make it better.