Genymobile / scrcpy

Display and control your Android device
Apache License 2.0
107.77k stars 10.4k forks source link

How to enable adb over TCP/IP without USB cable #1081

Open recnac-itna opened 4 years ago

recnac-itna commented 4 years ago

First I want to say it is a really cool project and I have learned a lot from it. Thanks.

In my scenario, I want to mirror android to android by wireless. "tailcode" has provided a solution. But I found we still need to "enable adb over TCP/IP on your device: adb tcpip 5555" by USB cable. Using USB debug is inconvinient in my scenario. So how can we make this step in Android application?

I have googled and tried, this post mentioned that we can apply for "su" previledge, "setprop service.adb.tcp.port 5555" and restart adbd. But I have no permission to access "su" even in rooted device. I am stocking here now.

That is what I tried so far. Actually I want to ask how can I enable adb over TCP/IP in Android application instead of USB cable? Other solution is OK too. Thanks for any help.

skourismanolis commented 4 years ago

I was able to enable the tcp/ip ADB through the developer options. In my Android 9 device it's in Settings > System > Advanced (it's just a dropdown) and the Developer Options. There is a section called "Debugging" with an option "ADB over network", once I enable that, it shows my local ip with the port 5555. If you can't find the Developer Options, make sure the option is enabled but tapping 5 times in quick succession on you device's build number (Found usually in settings below the android version).

More info on how to enable and access the Developer Options can be found here and here

recnac-itna commented 4 years ago

Thanks for your reply. But I can not find the "ADB over network" in "Debugging" from my Android devices (both OPPO and Xiaomi). Sorry I didn't make it clear. Actually my point is make this operation transparent to users, so I want to achieve this step in android code. Is that possible?

mukul29 commented 4 years ago

You usually need root permissions to enable ADB over Wi-Fi unless you're using a custom ROM which allows you to do it.

See this thread on Stack overflow for more info

skourismanolis commented 4 years ago

unless you're using a custom ROM

I am using a custom ROM so apparently that's why I have it.

surajgju commented 1 year ago

I was able to connect without usb cable. For that you need to enable wireless debugging in you android(mine was 12) phone. After enabling wireless debugging in developers options. You can see ip address and port enter same. 1)adb connect ip:port 2)if you are using Android studio then open device manager> physical device> pair using wifi> qr code will popup scan qr code from wireless debugging menu options and your device will get connected