adb-pair
Pair wirelessly with an Android device
TLDR
View documentation for adb pair
SYNOPSIS
adb pair <host>:<pairing_port> [<pairing_code>]
PARAMETERS
<host>
The IP address of the Android device to be paired. This is typically displayed on the device's 'Wireless debugging' settings screen.
<pairing_port>
The dynamic port number displayed on the Android device specifically for the pairing process. This port is distinct from the regular ADB connection port (e.g., 5555).
[<pairing_code>]
An optional 6-digit alphanumeric code displayed on the Android device for verification during the pairing process. If omitted, adb-pair will prompt the user to enter the code interactively.
DESCRIPTION
The adb-pair command is a crucial component of the Android Debug Bridge (ADB) suite, specifically designed to establish a secure, encrypted wireless debugging connection with an Android device. Introduced with Android 11 (API level 30), it provides a more robust and user-friendly alternative to the previous adb tcpip method for initial wireless setup.
Unlike adb connect, which is used for establishing a direct debugging session, adb-pair is a one-time authentication process. It facilitates the secure exchange of cryptographic keys between the host machine and the Android device. This process typically involves the device displaying a unique IP address, a dynamic pairing port, and a six-digit pairing code. The user then provides this information to the adb-pair command on the host.
Once successfully paired, the device remembers the host, and subsequent debugging sessions can be initiated using adb connect with the device's standard ADB connection port (typically 5555). This separation of pairing and connection enhances security by requiring an explicit, localized confirmation (the pairing code) for the initial trust establishment.
CAVEATS
Android Version Requirement: Wireless debugging via adb-pair requires an Android device running Android 11 (API level 30) or later.
Network Connectivity: Both the host machine and the Android device must be connected to the same Wi-Fi network.
Wireless Debugging Enabled: The 'Wireless debugging' option must be enabled in the Developer options on the Android device.
Firewall Considerations: Ensure that your host machine's firewall is not blocking outbound connections to the device's pairing port and subsequent connection port.
One-Time Pairing: adb-pair is for initial setup. After successful pairing, use adb connect for debugging.
Port Distinction: The pairing_port is dynamic and different from the standard ADB connection port (e.g., 5555).
WIRELESS DEBUGGING WORKFLOW
The typical workflow for wireless debugging using adb-pair involves the following steps:
1. On your Android device, navigate to Settings > Developer options > Wireless debugging and enable it.
2. Tap on 'Wireless debugging' to view its details. Note down the IP address and the Pairing port, and the 6-digit pairing code.
3. On your host machine, open a terminal and execute: adb pair <device_ip_address>:<pairing_port>
4. When prompted, enter the 6-digit pairing code displayed on your Android device.
5. Upon successful pairing, you will see a confirmation message. The device is now authenticated.
6. To start a debugging session, use adb connect with the device's IP address and the standard ADB connection port (usually 5555): adb connect <device_ip_address>:5555
7. Verify the connection using adb devices. Your device should now be listed as connected over Wi-Fi.
HISTORY
The adb-pair command was introduced as part of the Android 11 (API level 30) release in September 2020. Its development was driven by the need for a more secure, user-friendly, and streamlined approach to wireless debugging, addressing limitations and security concerns of the older adb tcpip method. It incorporates modern networking features like mDNS for discovery and a secure pairing flow, making wireless debugging a more integrated and reliable experience.