The wireless adb connection works fine on my Android 11 phone + Windows workstation.
But it's not convenient, as every time the phone Wifi disconnects/reconnects, I have to:
adb connect 192.168.1.10:XXXXX
on the computer.Is there a way to skip step 2, by either:
If you are an Android developer, I am 100% sure you might already be frustrated with debugging your App with ADB while being connected through a USB cable. If you didn't know already, you can connect to your Android Device with ADB over Wifi.
When the server starts, it binds to local TCP port 5037 and listens for commands sent from adb clients—all adb clients use port 5037 to communicate with the adb server. As shown, the emulator connected to adb on port 5555 is the same as the emulator whose console listens on port 5554.
You can make the port fixed until reboot by adb tcpip
After pairing and connecting with the dynamic port
try adb tcpip 4444
then you can use
adb connect ip:4444
until reboot (ya after reboot you've to connect with dynamic port and set tcpip to 4444 again)
You can dynamically get port using nmap
and connect to it.
here is my solution
adb connect <device_ip>:$(nmap $IP -p 37000-44000 | awk "/\/tcp/" | cut -d/ -f1)
Scanning only ports 37000-44000 is sufficient Also wireless debugging should be enabled and device needs to unlocked during nmap scan. Run it again if the nmap doesn't find the port first time.
I have added the command to an alias so it is easy to run
ex:alias adbw='adb connect 192.168.0.7:$(nmap $IP -p 37000-44000 | awk "/\/tcp/" | cut -d/ -f1)'
To connect next time:
adbw
if alias set.Ex Output:connected to 192.168.0.7:38395
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With