Adb Change Device

  1. Android Debug Bridge (ADB) is a command-line tool that allows you to communicate with a device. It is used to bridge communication between an emulator instance (Android device) and the background running daemon process (server).
  2. The device serial number (as reported by ‘adb devices’) appears to be set in the kernel, under arch/arm/plat-s5p/devs.c (look for ‘deviceserial’). This may be different for your device, I’d suggest a grep through the kernel sources for the device ID that is reported by adb devices.
  3. To connect your board to Wi-Fi, first access a shell prompt on the device. You can use either of the following methods: Open a shell over adb with the adb shell command. For the Raspberry Pi, first connect your board to your Wi-Fi router or development computer to assign it an IP address. Run the adb connect command to connect to.
  4. Connect device using USB cable to the host computer. Confirm USB debugging is enabled in device. Set target device to connect TCP/IP on port 5555. $ adb tcpip 5555. Now, disconnect the USB cable from the device. In Android device find the IP address from Settings wi-fi Setting Advanced IP Address.

What is Android Debug Bridge (ADB)?

Android Debug Bridge (ADB) is a command-line tool that allows you to communicate with a device. It is used to bridge communication between an emulator instance (Android device) and the background running daemon process (server). It helps you perform different actions like installing or debugging a device and run various commands on a device by providing access to a Unix shell.

Alternatively to adb you can also use telnet to connect to the device. This allows you to simulate certain things, e.g. Incoming call, change the network connectivity, set your current geocodes, etc. Use 'telnet localhost 5554' to connect to your simulated device. To exit the console session, use the quit or exit command.

Using any real device for mobile automation Testing has always been a challenge for testers. But, Android offers a handful of solutions to connect a real device over USB (Universal Serial Bus), i.e., Android Debug Bridge (ADB).

In this tutorial, you will learn-

USB debugging and ADB Configuration-

APPIUM offers an advantage to execute test on real devices. But prior to run the test, we need to setup following pre-requisite.

  • USB debugging should be enabled
  • ADB configuration
  • Desired capability setup as per the hardware changes.

Here we will see both, connecting to emulator as well as with real device for testing. See steps below for connecting to an emulator.

Adb change device language

How to Connect to an Emulator

Pre-Requisite- SDK (Software Development Kit) should be installed on the machine. ADB in Android is packaged with Google's Android SDK (Software Development Kit). Steps to enable ADB from SDK Manager.

Step 1) Open Android SDK folder

Step 2) Double click on SDK Manager

Step 3) From the list of all packages select Tools and mark the checkbox for

  • Android SDK Tools and
  • Android SDK Platform-tools.

How to Connect Android Device with ADB (Android Debug Bridge)

Step 1) Enable USB Debugging on your device

Enable USB debugging option from 'Developer Option' in Android phone. Now, connect your Android device to the computer using USB cable.

Step 2) Go to the Android SDK folder

Open the local folder where Android SDK files has been saved 'Android SDK >> Platform-tools' eg: C:android-sdkplatform-tools

Step 3) Open the Command window

Inside folder hold Shift + Right click menu >> Select 'Open command window here' option.

It will open the folder using command prompt.

Note- you can also open the folder path directly from the Run command in command prompt.

This command window will directly open the folder in command prompt window.

Step 4) Connect an external Android device

Now, prior to check the device, user have to connect an external Android device (mobile phone). To connect use the device USB cable connector to the system. Then in above command prompt type command-

It will display all list of all the connected devices.

But, prior to this we should check that ADB server. Check whether it is running as background process or not. Just open the command prompt from above mentioned procedure and write 'adb' and press enter. It should display all the adb's process running.

When server starts, it always bind the local TCP port 5037. All ADB clients listen to 5037 TCP port to communicate with server request.

Now, the running ADB server can scan all connected emulator or device instances by scanning the port.

Always remember that ADB daemon runs on odd numbered port between the ranges of 5555 to 5558.

ADB daemon process runs with console connection that acquires even number port for connection.

For example: If single device connected then server automatically scan the device and get connected but if multiple device or emulator running the user need to give ADB connect to device USB command line instruction to connect.

The emulator instance connected on odd numbered port 5557 has the same console running over even numbered 5556 port ie. Each running devices has 1 odd and 1 even connected port.

Command to detect all connected device -

Command detecting a single device from multiple connected devices-

It will detect the adb connection for device -5554 and install the application.

So, this way user can set up a successful connection to access ADB USB connect instances using ADB commands.

How to Configuring ADB for Wi-Fi Support

Just like configuring ADB connect USB, user can also configure ADB over wi-fi.

Pre-requisite

  • Both Android device and the host computer should be connected to same wireless network and
  • Device Bluetooth option should disabled.
Steps to connect-
  1. Connect device using USB cable to the host computer. Confirm USB debugging is enabled in device.
  2. Set target device to connect TCP/IP on port 5555
  1. Now, disconnect the USB cable from the device.
  2. In Android device find the IP address from Settings >> wi-fi Setting >> Advanced >> IP Address.

    Use the same Android Debug Bridge IP address to connect the device via ADB connect device USB connection

Hence, the final configuration done and 'adb' successfully configured over wireless network.

NOTE- If any connection error occurred just reset or kill the adb host connection. For that use following command

<adb kill server> and again ADB connect to phone from first step.

What is Android Debug Bridge (ADB)?

Android Debug Bridge (ADB) is a command-line tool that allows you to communicate with a device. It is used to bridge communication between an emulator instance (Android device) and the background running daemon process (server). It helps you perform different actions like installing or debugging a device and run various commands on a device by providing access to a Unix shell.

Using any real device for mobile automation Testing has always been a challenge for testers. But, Android offers a handful of solutions to connect a real device over USB (Universal Serial Bus), i.e., Android Debug Bridge (ADB).

In this tutorial, you will learn-

USB debugging and ADB Configuration-

APPIUM offers an advantage to execute test on real devices. But prior to run the test, we need to setup following pre-requisite.

  • USB debugging should be enabled
  • ADB configuration
  • Desired capability setup as per the hardware changes.

Here we will see both, connecting to emulator as well as with real device for testing. See steps below for connecting to an emulator.

How to Connect to an Emulator

Pre-Requisite- SDK (Software Development Kit) should be installed on the machine. ADB in Android is packaged with Google's Android SDK (Software Development Kit). Steps to enable ADB from SDK Manager.

Step 1) Open Android SDK folder

Step 2) Double click on SDK Manager

Step 3) From the list of all packages select Tools and mark the checkbox for

  • Android SDK Tools and
  • Android SDK Platform-tools.

How to Connect Android Device with ADB (Android Debug Bridge)

Step 1) Enable USB Debugging on your device

Enable USB debugging option from 'Developer Option' in Android phone. Now, connect your Android device to the computer using USB cable.

Step 2) Go to the Android SDK folder

Open the local folder where Android SDK files has been saved 'Android SDK >> Platform-tools' eg: C:android-sdkplatform-tools

Step 3) Open the Command window

Inside folder hold Shift + Right click menu >> Select 'Open command window here' option.

It will open the folder using command prompt.

Note- you can also open the folder path directly from the Run command in command prompt.

This command window will directly open the folder in command prompt window.

Step 4) Connect an external Android device

Now, prior to check the device, user have to connect an external Android device (mobile phone). To connect use the device USB cable connector to the system. Then in above command prompt type command-

It will display all list of all the connected devices.

But, prior to this we should check that ADB server. Check whether it is running as background process or not. Just open the command prompt from above mentioned procedure and write 'adb' and press enter. It should display all the adb's process running.

When server starts, it always bind the local TCP port 5037. All ADB clients listen to 5037 TCP port to communicate with server request.

Now, the running ADB server can scan all connected emulator or device instances by scanning the port.

Always remember that ADB daemon runs on odd numbered port between the ranges of 5555 to 5558.

ADB daemon process runs with console connection that acquires even number port for connection.

For example: If single device connected then server automatically scan the device and get connected but if multiple device or emulator running the user need to give ADB connect to device USB command line instruction to connect.

The emulator instance connected on odd numbered port 5557 has the same console running over even numbered 5556 port ie. Each running devices has 1 odd and 1 even connected port.

Command to detect all connected device -

Command detecting a single device from multiple connected devices-

It will detect the adb connection for device -5554 and install the application.

So, this way user can set up a successful connection to access ADB USB connect instances using ADB commands.

How to Configuring ADB for Wi-Fi Support

Just like configuring ADB connect USB, user can also configure ADB over wi-fi.

Pre-requisite

  • Both Android device and the host computer should be connected to same wireless network and
  • Device Bluetooth option should disabled.
Steps to connect-
  1. Connect device using USB cable to the host computer. Confirm USB debugging is enabled in device.
  2. Set target device to connect TCP/IP on port 5555
  1. Now, disconnect the USB cable from the device.
  2. In Android device find the IP address from Settings >> wi-fi Setting >> Advanced >> IP Address.

    Use the same Android Debug Bridge IP address to connect the device via ADB connect device USB connection

Hence, the final configuration done and 'adb' successfully configured over wireless network.

NOTE- If any connection error occurred just reset or kill the adb host connection. For that use following command

Adb Change Device Id

<adb kill server> and again ADB connect to phone from first step.