19

There doesn't seem to be much written on this, but I see an option to pair my device with a QR code scanner. Is there a way to pair my phone with my computer by generating a QR code on my computer and scanning it from my phone?

I'm running Ubuntu 20.04.

I'm using the Pixel 4a running Android 11.

The Pair with QR code option

0

4 Answers 4

11

This answer explains the background history of the built-in feature in Android Studio. For the technology used and 3rd-party software, you can read my answer here.


As of 26 January 2022, the feature can be used on the stable version of Android Studio Bumblebee 2021.1.1 with Android 11+ devices. Though, the performance may still be buggy on some platforms.

Background History

While the revamped wireless debugging has been known since

  • the source code commits in October 2019 by XDA

    On the user-side, Google plans to add a new “wireless debugging” switch in Developer Options that supports pairing devices by scanning a QR code or entering a 6 digit code.

  • the release of Android 11 DP2 in March 2020, as reported by 9 to 5 Google and Android Police

it was first introduced officially on Android 11: Developer Preview 3 in April 2020.

Wireless Debugging - In Android 11, we’ve completely revamped the debugging experience using ADB over a Wi-Fi connection. With limited USB ports on laptops, and a myriad of USB cables & connections to manage, the Wireless Debugging feature in Android 11 can help you be more productive. Unlike the existing TCP/IP debugging workflow, Wireless Debugging on Android 11 does not need a cable to set up, remembers connections over time, and can utilize the full speed of the latest Wi-Fi standards. In DP3, use the pairing code workflow to get started with this developer feature. We plan to add an integrated experience for Wireless Debugging with QR code scanning in a future Android Studio release, but we want to get your early feedback on the command line tool offered in Android 11 DP3. For details, see the documentation.

(Emphasis added, link fixed)

However, it was not until December 2020 that the new Android Studio Canary version, Android Studio Arctic Fox (2020.3.1) shown the pairing interface for the first time.

Lastly, for those running MacOS (other platforms are coming soon) with the latest Android Platform tools and an Android 11 device, you can try out the IDE integration for the Wireless ADB feature by going to the Run device selection dialogue → Pair Devices Using Wi-Fi.

Menu to access Wireless ADB feature

Wireless ADB Setup Window

2
  • That's pretty cool. I use adb on the command line so I was half expecting some ncurses based qr code generation thing haha. Maybe in the future who knows.
    – joshpetit
    Mar 8, 2021 at 14:46
  • 3
    I found out in the meantime that you need to use the ’adb pair’ to pair, but it's guess you can do this just by using a USB cable too. When paired you can use ‘adb connect‘ to connect the device.
    – rekire
    Nov 1, 2021 at 6:42
7

You can pair your phone wirelessly using ADB by following these steps:

  1. Make sure your phone and laptop are on the same network.
  2. Open the following menu on your phone: Settings>Developer options>Wireless debugging. Enable the feature and then click on Pair device with pairing code on the same screen.
  3. Open a terminal on your laptop and use the below command to pair your phone with your laptop:
adb pair host:port code

You can find host, port and code on your phone screen after clicking on Pair device with pairing code in the wireless debugging menu.
4. Run the below command to make sure the pairing has been done successfully:

adb devices
3
  • I appreciate the answer, but that wasn't my question. The question has to do with the fact that there is a way to pair a phone using a QR code and I was wondering how you could do that instead of using the code.
    – joshpetit
    Jul 19, 2022 at 20:39
  • 1
    appreciate this was not what the OP was looking for, but I came here via Google and this was exactly what was needed.
    – redDevil
    Sep 27, 2022 at 22:18
  • After doing adb pair, you also need to adb connect host:port. The connect port is not the same as the pairing port (though the IP should be the same).
    – Tobu
    Nov 16 at 23:27
5

This answer explains the technology used and 3rd-party software. For background history of the built-in feature in Android Studio, you can read my answer here.


Android 11 and ADB utilize multicast DNS (mDNS) for its wireless pairing.

ADB 30.0.0 added support for wireless pairing, including commands like:

  • adb pair to pair the Android device with the host machine using pairing code

  • adb mdns check to check which mDNS daemon is used

    • On Windows, using Openscreen discovery added in ADB 31.0.2:

      C:\android-sdk\platform-tools> adb mdns check   
      mdns daemon version [Openscreen discovery 0.0.0]
      
    • On Windows, using Bonjour service

      C:\android-sdk\platform-tools> adb mdns check
      mdns daemon version [2140303]
      
  • adb mdns services to list available mDNS services created by the Android devices

    C:\android-sdk\platform-tools> adb mdns services
    List of discovered mdns services
    adb-941AY0HXWG-r8Nucn   _adb-tls-connect._tcp.  192.168.0.147:37387
    adb-941AY0HXWG-r8Nucn   _adb-tls-pairing._tcp.  192.168.0.147:42885
    

In addition to the built-in feature in Android Studio, there is also some 3rd-party software that simulates the same process by generating a QR code to initiate the wireless pairing:

  • GitHub - benigumocom/debug_from_qr.py: an executable Python 3 script
    • Dependency packages:

    • Demo video: YouTube - BENIGUMO.COM - Pair device with QR code - Android11

    • Sample

      C:\> py .\debug_from_qr.py
      █████████████████████████████████
      █████████████████████████████████
      ████ ▄▄▄▄▄ █ ██▀▀ █ ▀█ ▄▄▄▄▄ ████
      ████ █   █ █  ▀█▄█▄▀▄█ █   █ ████
      ████ █▄▄▄█ █▀  █ ▄ ▄▄█ █▄▄▄█ ████
      ████▄▄▄▄▄▄▄█▄█ ▀▄▀ █▄█▄▄▄▄▄▄▄████
      ████ ▄██ ▄▄▀██▄▀▀▀ █ ▀█ █▄ ▄▄████
      ████▄▄▄▄▀▀▄▄▀ ▄█▄▄▀▄███▄▄████████
      ████ ▄▄ ▄█▄▀▀▀▀▀▀ ▄▀█▀▄▀▀ ▄▄▄████
      ██████▄█▀█▄▄ ▄██▄▄▀▄▄▄▀▄█▄▀▄▀████
      ████▄▄██▄█▄▄ ▄▀▀▄▀ ▀ ▄▄▄   ▀▀████
      ████ ▄▄▄▄▄ █▀▄█▄▄▄▀▄ █▄█  ▀██████
      ████ █   █ █▄ ███▀▄█ ▄▄  ▄▄▄ ████
      ████ █▄▄▄█ █▀▄█▄▄▄▀▀ ▄▄▄█▄▀ ▀████
      ████▄▄▄▄▄▄▄█▄█▄█▄▄█▄████▄▄██▄████
      █████████████████████████████████
      █████████████████████████████████
      Scan QR code to pair new devices.
      [Developer options]-[Wireless debugging]-[Pair device with QR code]
      Press enter to exit...
      
      Service debug._adb-tls-pairing._tcp.local. added.
      service info: ServiceInfo(type='_adb-tls-pairing._tcp.local.', name='debug._adb-tls-pairing._tcp.local.', addresses=[b'\xc0\xa8\x00\x93', b'\xc0\xa8\x00\x9f'], port=40067, weight=0, priority=0, server='Android-2.local.', properties={}, interface_index=None)
      
      adb pair Android-2.local.:40067 123456
      Successfully paired to Android-2.local.:40067 [guid=adb-941AY0HXWG-r8Nucn]
      Service debug._adb-tls-pairing._tcp.local. removed.
      Press enter to exit...
      
      
      List of devices attached
      adb-941AY0HXWG-r8Nucn._adb-tls-connect._tcp. device product:sargo model:Pixel_3a device:sargo transport_id:3
      
  • GitHub - saleehk/adb-wifi: an NPM command line interface (CLI) tool
    • Install: npm i adb-wifi -g

    • Usage: adb-wifi

    • Sample

      C:\> adb-wifi
      [Developer options]->[Wireless debugging]->[Pair device with QR code]
      ▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄
      █ ▄▄▄▄▄ █▄▀ ▀ ▀ █▄▄█▄▀▄▄ ██ ▄▄▄▄▄ █
      █ █   █ █   █▀  ▀▀█▄ █▀ ███ █   █ █
      █ █▄▄▄█ █▄█▀ ▄█▀▄█▄▄ █ ██▀█ █▄▄▄█ █
      █▄▄▄▄▄▄▄█▄█ █ █ █▄▀▄█ █▄▀▄█▄▄▄▄▄▄▄█
      █  ▄▄▀▀▄█▄█ ▄   ▄▀ ██  ██▄▄██▄▄▄▀ █
      █▀▀▀▀▄▀▄▄▄  ▄▄▀▄▀▀███▄█▄▄▀▀ ▀▀ ▄█▄█
      █▄▀ █▄▀▄█▀ ▄▀ ▄▄▄▀█▀▄▄▀ ▄  ▀ █▄▄█ █
      █▀ ██ ▀▄ ▀▀▀ █▄▀█ ▄▄ █ ▄▀ ▀  ▄█▀█▀█
      ██▄ ▄█▀▄█▄▀▄█▄ ▀▄█▀▄ ▀   ▀▄▄▀▀█  ▄█
      █▄▀▄▄  ▄▀█  ▀█▄▀▄ ▀ ▀ █ ▀█ █▄ ██ ▀█
      █ █▄ ▄▀▄ █  ██ ▄█▀▄▄▄▀   ███ ██▀▄▄█
      ██▀▄██▄▄ ▄ █▀▀ ▄█▄▄▄█ ██  ██▄ ▀█▄ █
      █▄█▄█▄▄▄▄ ▀█ ▄▀▄▄ ▀█▀  ▄▄ ▄▄▄ █▄ ▀█
      █ ▄▄▄▄▄ ██ ▀▀ █ ▀▀▄▀▄▄▀▀▀ █▄█ ▀▀▀██
      █ █   █ █▀ ▄▀▄▄█▄█▀▄█▀▀  ▄▄▄  ▄█ ▄█
      █ █▄▄▄█ █ █▄██▄█▄▄▀▀█▄▄▄▀█▀▀▀▀▀█▄▀█
      █▄▄▄▄▄▄▄█▄██▄▄██▄█▄███▄█▄█▄▄██▄▄███
      
      stdout: Successfully paired to 192.168.0.147:38629 [guid=adb-941AY0HXWG-r8Nucn]
      

mDNS Compatibility

Since this feature depends on mDNS, different operating systems may have different compatibility:


Additional references:

1
  • This should actually be the accepted answer, as it is the most detailed one with highest developer experience degree Aug 23 at 12:52
0

Just wanted to add that if you try to scan the QR code directly from the camera, like on a Pixel by pointing it at the QR code and clicking the link, it won't work. You will get an error message that says "QR Code contains incorrect WiFi password". This error message is a red herring, it has nothing to do with the WiFi password, you just can't pair with the QR code by scanning it with the camera

Instead, like is mentioned in Yandirr's answer, you have to go to:

Settings --> System --> Developer options --> Wireless debugging (Yes you can click the text) --> Pair device with QR code

Then when you scan the QR code it should work. I think it's bad UI design that you have to click on the "Wireless debugging" text since it looks like that's just a single radio button to toggle the Wireless debugging option, but in actuality there's an entire sub-menu hidden behind it.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .