Genymobile / scrcpy

Display and control your Android device
Apache License 2.0
108.52k stars 10.45k forks source link

Wireless not permanently enabled when turning on tcpip. #1548

Open robertsaron opened 4 years ago

robertsaron commented 4 years ago

Environment

Describe the bug A clear and concise description of what the bug is.

On errors, please provide the output of the console (and adb logcat if relevant).

Please paste terminal output in a code block.

Please do not post screenshots of your terminal, just post the content as text instead.

In a previous version of scrcpy, once wireless was enabled it would remain on. In version 1.14 I have to turn on the wireless option of scrcpy, or plug it in all the time to a USB connection.

I am on the latest version of android, and windows 10 Pro.

robertsaron commented 4 years ago

Information from Terminal:

INFO: scrcpy 1.14 https://github.com/Genymobile/scrcpy adb: error: failed to get feature set: no devices/emulators found ERROR: "adb push" returned with value 1 Press any key to continue...

When connected via usb, it works fine.

rom1v commented 4 years ago

In version 1.14 I have to turn on the wireless option of scrcpy

scrcpy has no "wireless option". It just uses adb, which can connect to the device over USB or TCP/IP via adb connect.

How did you connect to your device wirelessly via adb?

robertsaron commented 4 years ago

Yes I connected via adb over tcpip. In a previous version I could enable it once, and never connect my phone to my computers USB again. Today, after turning on my computer, I am not able to connect to my device over tcpip, which I will refer to as wireless, wifi, or wirelessy going forward.

I have to plug my phone into a USB port, after every reboot.

rom1v commented 4 years ago

After every reboot of the device or the computer? (adb tcpip does not survive device reboot)

Anyway, it's related to adb behavior, not scrcpy. The adb version changes between scrcpy releases, check a previous version to be sure.

mjjauhar commented 4 years ago

If you are on windows. Try creating a batch file, and put the batch file inside scrcpy folder and open that batch file instead of scrcpy.exe.

How to create and enable batch file in Windows

Here is what I put in my batch file:

@ECHO OFF 
:: Batch file for scrcpy wireless
TITLE scrcpy wireless
ECHO >> Make sure you enabled adb debugging on your device.
ECHO >> Plug your device via usb for the 1st time or if it's failing to start.
ECHO >> Connect the device to the same Wi-Fi as your computer.
:: step 1: Enable adb over TCP/IP on your device: adb tcpip 5555
ECHO =======================================
ECHO Enabling adb over TCP/IP on your device
ECHO =======================================
adb tcpip 5555
ECHO >> Unplug your device
:: step 2: Connect to your device: adb connect DEVICE_IP:5555 (replace DEVICE_IP).
ECHO =======================================
ECHO Connecting wirelessly to your device
ECHO =======================================
adb connect DEVICE_IP:5555
:: step 3: Run scrcpy as usual.
ECHO =======================================
ECHO starting scrcpy wielessly.
ECHO =======================================
scrcpy --bit-rate 2M --max-size 800
:: It may be useful to decrease the bit-rate and the definition
PAUSE
Uj947nXmRqV2nRaWshKtHzTvckUUpD commented 3 years ago

To permanently enable adb via wifi that will persist upon reboot, login as root in termux and issue command: setprop persist.adb.tcp.port 5555

No need to plug usb cable anymore afterwards.

robertsaron commented 3 years ago

@fusionneur Do I enable root through ADB on my android phone? Or turn on Root in the ADB shello, on my windows computer? I have looked on line for both, and need some help on both. Will you please elaborate.

Uj947nXmRqV2nRaWshKtHzTvckUUpD commented 3 years ago

While usb cable is connected:

  1. in termux: su setprop persist.adb.tcp.port 5555 setprop service.adb.tcp.port 5555 stop adbd start adbd

  2. Alternatively you can send the command with adb: adb shell 'su --command "setprop persist.adb.tcp.port 5555"'

    adb shell 'su --command "setprop service.adb.tcp.port 5555"' #this is not really needed in this case

    adb tcpip 5555 #if you want to start right away adb connect wlan0_ip:5555 #where wlan0_ip is the phone's wlan ip

You can get wlan0 ip with: adb shell 'su -c "ifconfig wlan0"'

scrcpy

you can unplug the usb cable.

Uj947nXmRqV2nRaWshKtHzTvckUUpD commented 3 years ago

I wrote a script to assist wireless connections.

https://github.com/fusionneur/ethernally

I tested in various scenarios and looks fine. If you find any problem, please open an issue. Thank you

robertsaron commented 3 years ago

@fusionneur any way to get this script to work on windows? I tried to follow your steps on my device using termux, and got my device rooted. Termux, tells me no su program found on this device. I also tried @mjjauhar batch file and that did not work either. So either I am doing something wrong, or wireless is just not for me.

Uj947nXmRqV2nRaWshKtHzTvckUUpD commented 3 years ago

you can run the shell script in windows through cygwin or windows subsystem for linux or through a linux virtual machine installed in vmware/virtualbox - in windows

Just one question.. you said "got my device rooted. Termux, tells me no su program found on this device. " but these 2 things contradict each other. Are you really rooted? You should have magisk installed if you're rooted and 'su' should work in termux in this case

robertsaron commented 3 years ago

I do not have magisk installed. When Rooting my device it wiped everything and I did not know that would happen. So I am not sure if I want to proceed. How hard is it to get magisk installed?

Uj947nXmRqV2nRaWshKtHzTvckUUpD commented 3 years ago

rooting itself shouldn't wipe, only unlocking bootloader wipes it - which is however a prerequisite step for first time rooting. What device do you have? Some devices are more tricky to root than others. Personally I follow xda guides that are device specific when rooting.

robertsaron commented 3 years ago

I have the Pixel2 XL. And yeah this was my first time rooting it. I unlocked the bootloader.

robertsaron commented 3 years ago

I somehow got the batch file working that another user posted. I am good on the wireless for now. Though I would at somepoint like to finish the root process.

Uj947nXmRqV2nRaWshKtHzTvckUUpD commented 3 years ago

for rooting I suppose you could follow this guide: https://www.youtube.com/watch?v=aMPRRQu1hCk

Uj947nXmRqV2nRaWshKtHzTvckUUpD commented 3 years ago

I created this tool to ease wireless connectivity. Check it out and let me know of your experience.

https://github.com/fusionneur/ethernally