Do I have to plug in the usb cable to activate wireless connection every time?
First of all, thank you for developing this tool. I can only use my right hand to use mouse. I can easily use my mobile via this tool on Ubuntu 22.04. It works well. I have a problem. Every time I have to plug in USB cable and do the followings:
adb devices
List of devices attached
adb tcpip 9990
adb connect 192.168.1.103:9990
scrcpy
Then I remove USB cable.
Inserting and removing USB cable is tiring or sometimes impossible to me.
You must connect an USB cable only once after each phone reboot (you can't keep the TCP/IP mode across reboots without a rooted device, this is an Android limitation).
The first time, plug your device and run scrcpy --tcpip.
The following times, just run scrcpy --tcpip=192.168.1.103.
For completeness, since Android 11, a wireless debugging option allows to bypass having to physically connect your device directly to your computer.
More details: https://github.com/Genymobile/scrcpy/blob/master/doc/connection.md#tcpip-wireless
@rom1v Thank you for the info. I'll test it.
I tried the commands on this link in both the platform-tools folder and in the scrcpy main folder and while it says it's paired to my phone, when i try doing "adb tcpip 5555" it gives the error: "error: no devices/emulators found", and if i try "scrcpy --tcpip=MYIPADDRESS:5555" it says: "INFO: Connecting to MYIPADDRESS:5555... cannot connect to MYIPADDRESS:5555: No connection could be made because the target machine actively refused it. (10061)
Try without scrcpy first (just adb): adb connect MYIPADDRESS:5555
No connection could be made because the target machine actively refused it. (10061)
https://stackoverflow.com/questions/57401663/no-connection-could-be-made-because-the-target-machine-actively-refused-it-100
It gave the same error: C:\platform-tools>adb connect MYIPADDRESS:5555 cannot connect to MYIPADDRESS:5555: No connection could be made because the target machine actively refused it. (10061)
Alright it seems i found a solution. First off i started a terminal inside the platform-tools folder, which is the android sdk platform tools package downloaded from this link. Then on android, in the wireless debugging menu i pressed "pair device with pairing code" which gave me an ip address, a port, and a password. In the terminal I then used the "adb pair IPADDRESS:PORT" command using the info from the phone, and then when asked for the password i entered that as well, and successfully paired. This is the important part though, I then used "adb connect" and then the ip address and port shown just below the "use wireless debugging" toggle in the menu, instead of using IPADDR:5555. This worked, and after that i simply CD'd into the scrcpy main folder and used the scrcpy command. Never once connected the phone to the pc through cable.
Eminic, thank you for the incredible fix! I have an s22u that has a borked USB port and I could not even begin the process of connecting to get scrcpy working, but your efforts have given me a solution. Thank you so much, this worked perfectly and I cannot thank you enough for being smart enough to get this working! If anyone else finds this, just follow his steps and you'll be connected quickly and completely wirelessly.
@Eminic Thank you for helping users with detailed information.
Just one remark:
First off i started a terminal inside the platform-tools folder
You don't need platform-tools, adb is in the scrcpy folder.
FYI, the Android documentation about this (the link is in the scrcpy documentation): https://developer.android.com/studio/command-line/adb#wireless-android11-command-line
Alright it seems i found a solution. First off i started a terminal inside the platform-tools folder, which is the android sdk platform tools package downloaded from this link. Then on android, in the wireless debugging menu i pressed "pair device with pairing code" which gave me an ip address, a port, and a password. In the terminal I then used the "adb pair IPADDRESS:PORT" command using the info from the phone, and then when asked for the password i entered that as well, and successfully paired. This is the important part though, I then used "adb connect" and then the ip address and port shown just below the "use wireless debugging" toggle in the menu, instead of using IPADDR:5555. This worked, and after that i simply CD'd into the scrcpy main folder and used the scrcpy command. Never once connected the phone to the pc through cable.
I tried it, and it works. However, on my phone, it only works once. When I turn off WiFi and then turn it back on, or when I leave and come back to reconnect to WiFi, the wireless debugging option will be automatically turned off. I need to manually turn it on and reconnect using this method. The solution is to connect to the computer using a USB cable and use the following commands in order:
adb tcpip YOURPORT adb connect YOURIP:YOURPORT scrcpy --tcpip=YOURIP:YOURPORT
This way, there's no need for wireless debugging, and it will work normally even after disconnecting and reconnecting to WiFi. And in every subsequent use (without restarting the phone), it will work normally without needing to connect the USB cable. This issue has bothered me for months :( Hope it will help others.
adb tcpip YOURPORT adb connect YOURIP:YOURPORT scrcpy --tcpip=YOURIP:YOURPORT
That's redundant.
Either enable adb TCP/IP and connect manually, then run scrcpy:
adb tcpip YOURPORT
adb connect YOURIP:YOURPORT
scrcpy
Either let scrcpy do the first commands automatically:
scrcpy --tcpip
More details: https://github.com/Genymobile/scrcpy/blob/master/doc/connection.md#tcpip-wireless
Here is what I found:
After following @rom1v 's guide on the last post I found that those instructions have to be repeated every time the wireless ADB connection is disconnected (usually on reboot or when the wireless debugging toggle switch is turned off in the developer settings.
Android turns off wireless debugging on reboot and also when wifi is disconnected, or turned off. To fix that you will need a rooted phone and install my tasker script which automatically turns on wireless debugging for both of these conditions. Like I said you need a rooted phone and then after importing it you also need to reboot your phone for some reason or it wont work.
Turn_Wireless_Debugging_On.prj.zip
Then you need to follow the instructions here and also set your phone to a static IP:
Then download my version which modifies the "scrcpy-noconsole.vbs" file with code from Chat gpt. Also make sure you edit the "Autoconnect ADB wireless (Edit this to add your phone's static IP).bat" file with your phone's actual IP. There is a shortcut in that folder which you can pin on your start menu. I have rebooted my phone 5 times so far and clicking on that shortcut fires up screen copy on my phone every single time. The only downside to this is it requires your phone to be rooted to run the tasker script to automatically turn on wireless debugging.
Ahhh... Don't you love how complicated it is to be able to use your phone from your PC? (not dissing on the dev here but android certainly made it silly).