Before android 11, i was able to wirelessly debug apps using this method
The problem is Android 11 introduced Wireless Debugging and the above method doesn't work as expected. And the wireless debugging mode cannot be turned on unless my android phone is connected to wifi so it is not working because I want to use the target phone's hotspot for wireless debugging.
is there any possible solution? or is it possible to turn the wireless debugging mode ON even if the phone is not connected to wifi?
Work Around
adb tcpip 5555
adb connect [ip]
android 11 and 12
go to Settings/Display & brightness/Auto screen off and make it 30 minutes. (means that your phone won't auto lock so it will stay wirelessly connected to ADB)- android 13 and above do not disconnect you if your device gets locked
- I hope android engineers will allow using the wireless debug feature without being connected to WiFi in newer versions of android though, as pointed to in the question.
Bonus info:
Your phone has two ip addresses, one from your Internet Provider (in Settings/About/Status) that changes whenever you turn off your Mobile Data and one that your hotspot creates as a router (you can get it from your PC when you connet to your phone's hostpot) that does not change (sometimes does change if you restart your phone, though
macOS: after step 1 above, if you run netstat -nr | grep default
you will get the router's (Your phone in this case) ip address in the first line 'default gateway' (For windows ipconfig
in cmd)
Mac only
I also made aliases for the terminal
alias adb_s='adb tcpip 5555'
alias adb_sc='adb tcpip 5555 && adb connect $(netstat -nr | grep default | awk '\''$2 ~ /\./ {print $2}'\'')'
alias adb_c='adb connect $(netstat -nr | grep default | awk '\''$2 ~ /\./ {print $2}'\'')'
Now, when i run (single command):
adb_sc = device starts in tcpip mode and gets connected wirelessly
adb_c = device gets connected wirelessly if already in tcpip mode
adb_s = device starts in tcpip mode
You can copy the aliases above into .zshrc
{/Users/[your-username]/.zshrc (for zsh terminal)} file and can enjoy the convenience as well.