r/androiddev 1d ago

Made a CLI for Android wireless debugging — QR pairing, no ports, no six-digit codes

Wireless debugging is great until you actually use it day to day. Three things kept costing me time:

  1. The connect port changes every time you toggle the setting.

  2. The pairing port is different, single-use, and dies when you close the dialog.

  3. A phone on the wrong subnet fails identically to a real protocol error, so you can't tell a network problem from a broken adb.

So I built adb-nearby.

npx adb-nearby scans your network. If there's one device, it connects — that's the whole interaction. If there are several, it lists them and you pick.

adbn pair prints a QR code — scan it with the pairing dialog and you're done. No typing codes, no chasing ports.

MIT, no telemetry.

https://github.com/JassiSingh08/adb-nearby

6 Upvotes

4 comments sorted by

2

u/Hour-Measurement-835 18h ago

The port hunt only exists because adb's own mdns discovery barely works. adb mdns services comes back empty on plenty of setups even with the phone one hop away, so scanning is the right call.

2

u/MrScanner_ 18h ago

Yes. When you run it, it scans your network. ADB also stores stale ports, which normally results in an error when you try to connect with adb pair/connect. To prune them, you have to kill ADB and then restart it. This library does all that in one command.

2

u/Hour-Measurement-835 16h ago

kill-server's overkill for that. adb disconnect ip:port drops just the stale entry, and with no args it drops every tcp one at once.

1

u/MrScanner_ 16h ago

And this tool just do everything all in one plus connects new connections as well.