I'm developing an application (using Eclipse + Android SDk/NDK) which uses the micro-usb port on an android phone to connect to peripherals. I am trying to connect to the ADB daemon on the phone via WiFi (tcp port 5555) so I can debug my application in Eclipse. However, I just can't get this to work.
Nothing I try actually results in the ADB daemon on the phone switching to TCPIP mode (as far as I can tell by looking at the output of getprop). The issue seems to be that I can't set the relevant service.adb.tcp.port property on the phone. The development phone I am using is an LG GT540 running CyanogenMod 7.0.0 (Android v2.3.3). Development machine is iMac running OS X Lion.
Here is some relevant information on what I have tried/confirmed/discovered:
The phone is rooted (ru.secure = 0)
Connecting to ADB via USB works fine
The adb service on the Mac is running as root (adb root)
adb shell gives me a shell with super-user access (# prompt, su, ability to edit system files etc)
adb tcpip 5555 does not complain or throw errors when run from a terminal window on the mac but does not set the service.adb.tcp.port property on the phone
setprop service.adb.tcp.port 5555 entered at the # prompt of a terminal window on the phone does not complain or throw errors but does not set the service.adb.tcp.port property
setprop persist.service.adb.enable 0 works from both Mac and phone shells (confirmed by checking ADB daemon stops and getprop returns 0 for the enable property)
setprop persist.service.adb.enable 1 works fine from both Mac and phone shells (confirmed by checking ADB daemon starts and getprop returns 1 for enable property)
The only properties on the phone relating to ADB on the phone are persist.service.adb.enable and init.svc.adbd (if ADB is running)(confirmed by getprop | grep adb on the phone)
Apps on the market that purport to 'automatically' configure ADB for Wifi (such as WiFi ADB) do not work either (tcp.port property is not set and ADB over TCP does not work)
Am I looking too hard here and missing something obvious? There are many posts and articles on the Internet relating to problems getting ADB to work over TCP but they all relate to phone rooting issues.
Is anyone able to shed some light on why I can't seem to set this particular property or suggest any other issue that may be preventing the ADB daemon from running in TCPIP mode?
You need to stop and then restart adbd on the phone for the tcp port property to take effect.
setprop service.adb.tcp.port 5555
stop adbd
start adbd
With any device (rooted or not) it really ought to be as simple as:
Connect to USB
Run adb tcpip <port>
You will see restarting in TCP mode port: <port> spit out the terminal if it worked. If you see nothing, it didn't.
The property is set for you by the daemon. Tutorials telling you to set the propery and reboot adbd are focused on code that needs to execute on-device (i.e. if you are writing an ADB over WiFi app).
However, you mentioned you are using Cyanogenmod. Doesn't CM have an "ADB over Network" setting in Developer Options (I swear it was there in CM7)? I know that their chosen port is 5555. You may be running into conflicts with that feature trying to do it manually. Probably best to use what's built into the system if it's there.
1 line to add on start of application.
setprop service.adb.tcp.port 5555 && stop adbd && start adbd
This resets adb on start!
Related
I cannot use adb connect to connect via WiFi to my device (Nexus 5, Android 6), but since I'm developing a cordova plugin using USB OTG, I really need to connect via WiFi.
I tried to adb kill-server, and all solutions provided on SO, and none is working for me...
Before it was working ok (i.e android 5).
Any idea?
I had the same issue since the android 6 upgrading.
I noticed that for some reason the device is playing "hard to get" when you try to contact it over WIFI.
Try these following steps:
Make sure that Aggressive Wi-Fi to Cellular handover under Networking section in the device's developer options is turned off.
ping continuously from your pc to the device to make sure it's not in network idle mode ping -t 192.168.1.10 (windows cmd), unlock the device and even try to surf to some website just to make it get out of the network idle.
If ping doesn't work, turn off / on Android Wifi and go back to step 2.
When it replies to the ping, connect it via usb, and:
adb usb
adb tcpip 5555
adb connect 192.168.10.1:5555
In case it's still not connected, try to switch the USB connection mode as MTP / PTP / Camera while the device is connected through USB and repeat these steps over again...
If the above points are not working please try running ADB as admin.
For Ubuntu -
`sudo adb start-server`
I had the same issue. i tried all commands like adb kill-server then
adb tcpip 5555 then
adb connect <IPAddress>:5555 but the issue remain same
the IP address which i used to connect ... showing me message unable to connect .....
what i did is
go to phone's settings
then About phone
then Status`
then check IP address
Now try to connect phone with that IP address
Note : - The problem is the IP address changed which i used to connect
First, you need to pair your computer :
Go to Wireless debugging > Pair device with pairing code.
Go to console of your pc and run adb pair ip:port pairing_code
Now , run adb connect ip:port on your pc and enjoy.
Go to Android Studio and you can the see new device.
I had the same problem. The solution was as follows.
In Developer Options.
+ Activate "Allow ADB debugging in load only mode."
+ In Spanish, "Permitir depuraciĆ³n ADB en modo solo carga."
Explanation
My problem was as follows: I was doing all the steps:
adb kill-server
adb start-server
adb tcpip 5555
adb connect (your ip).
After completing these steps, I disconnected the phone from the USB cable, and the connection was lost, I could not make the wireless connection.
However, this worked for me on a Huawei ALE-23 cell phone, but it did not work for me on the Huawei Y9S cell phone (Android 10), it failed.
I solved it only by activating the option "Allow ADB debugging in load only mode" in the cell Huawei Y9S.
Cheers!!!.
Make sure you are not connected to a VPN. I was able to connect to adb as soon as I disconnected from the VPN. For a sure way to connect do this:
Unplug USB
Restart Android device
Shutdown Android Studio or any other IDE using ADB
adb kill-server
Plug back in USB after restart
adb devices This automatically starts the server. You sould see the device plugged in via USB
adb shell ip addr show wlan0 to get your devices IP address
adb tcpip 5555 Set the port to 5555 that you want to connect through
adb connect 192.168.0.6:5555 Replace IP address with one from step 6.
Disconnect the USB
I used the same approach as #IVAN MANJARREZ ADB : unable to connect to 192.168.1.10:5555
The only difference was I used Huawei - p20 pro.
Where for p20 - pro, you have to search for and activate
"Allow ADB debugging in charge only mode"
I have tried everything but still, nothing worked for me. Then randomly, I used the following command:
$ adb tcpip 5555
error: no devices/emulators found
$ adb connect 192.168.0.104:5555
failed to connect to 192.168.0.104:5555
$ adb connect 192.168.0.104:5555
already connected to 192.168.0.104:5555
It was connected at this point but my device was offline. I was always able to connect at the second attempt but my device was always offline. At this point, I connected my device to my PC with USB.
$ adb tcpip 5555
error: more than one device/emulator
$ adb disconnect
disconnected everything
$ adb tcpip 5555
restarting in TCP mode port: 5555
$ adb connect 192.168.0.104:5555
connected to 192.168.0.104:5555
I disconnected my USB and voila! my device was still connected.
I am sorry but I can't explain why it worked. I was randomly trying different things on internet. I had used the same commands several times but in different orders but they didn't work. I hope it will help someone.
I solved this problem by disabling USB debugging and enabling it again
The critical step in getting this to work is disconnecting the usb cable after issuing the adb connect xx.x.x.xx:5555 command. At this point you are connected but unauthorized.
Execute adb kill-server and re-issue the connect command.
Verify with execution of adb shell date.
Similar issue happened to me when I tried to connect wirelessly to my phone. I got this error:
failed to connect to 192.168.1.187:42534
I tried to restart everything, phone, PC, adb server. The issue was simply that you have to connect by cable first to authorize the client and then you can unplag the cable and connect wirelessly.
In my case I had to shut of and on the wifi adb debugger app, on the device.
On another USB device I had to shitch off and on developer mode, then re-set the development options.
Also reset my pc.
Seem that adb in some way made a mess with global communication and all the debug communication have to be reset on both sides.
After this the devices start to comunicate again
sudo adb start-server
Just worked for me. after A day of looking for a solution.
So my situation was that i restarted it in tcp mode but still couldn't connect, i had an No route to host error ,so i tried pinging it but i couldn't find it either even though it was on the arp table. so what i noticed was that when i connect it by usb, it pings successfully. so i had to do the adb connect ip before i could unplug the usb.
I ran into this same issue on not being able to connect via Wi-Fi but was using the snap version of scrcpy. I kept seeing messages like adb server version (40) doesn't match this client (39); killing... when I would run adb or scrcpy commands but it still worked, until I tried to connect over Wi-Fi.
$ scrcpy
INFO: scrcpy 1.16 <https://github.com/Genymobile/scrcpy>
adb server version (40) doesn't match this client (39); killing...
* daemon started successfully
adb: error: failed to get feature set: no devices/emulators found
ERROR: "adb push" returned with value 1
I believe this means it was unable to push the server app to the device.
Running the commands to setup Wi-Fi using the adb built into the snap, scrpy.adb solved this for me.
$ scrcpy.adb tcpip 5555
$ scrcpy.adb connect 192.168.1.25:5555
connected to 192.168.1.25:5555
$ scrcpy
INFO: scrcpy 1.16 <https://github.com/Genymobile/scrcpy>
/usr/local/share/scrcpy/scrcpy-server: 1 file pushed. 0.6 MB/s (33622 bytes in 0.051s)
[server] INFO: Device: XXXXX XXXXXXX (Android 9)
INFO: Renderer: opengl
INFO: OpenGL version: 4.6.0 NVIDIA 390.25
INFO: Trilinear filtering enabled
INFO: Initial texture: 1440x2560
connect using USB and Just use this command
adb tcpip 5555
It will restart services
and then adb connect <device-ip>:5555
Note: to find device IP, you can navigate to wifi -> YOUR_NETWORK -> IP address
I faced the same issue with the ADB over WiFi connection between my Android 10 phone and Windows 10 PC, which was OK before and suddenly this happened. After reading this question and answers above, I first turned off WiFi on my router and turned it back on.(I repeat not the router, just WiFi) It worked.
I created this powershell script that automates the connection to the phone, to make it work follow the steps and reassign the variables to make it work on your device
#Important!!!
# Enable developer options on your phone and follow the steps below:
# Step 0: Developer options > (USB debugging = true) and (Permanently accept the digital signature of the computer)
# Step 1: Developer Options > Active Screen = true
# Step 2: Developer options > Allow ADB debugging in load-only mode = true
$customPort = '5555'
$ipPhone = '192.168.1.53'
$fullIpPhone = $ipPhone + ':' + $customPort
Write-Host
Write-Host '=============Start script============='
adb usb
Write-Host
Write-Host '=============Start clean network============='
adb devices
adb disconnect
adb kill-server
adb devices
Write-Host
Write-Host '=============Start connection============='
adb tcpip $customPort
# adb tcpip 5555 # $customPort
adb connect $fullIpPhone
# adb connect 192.168.1.53:5555 # $fullIpPhone
adb devices
Write-Host
Write-Host '=============End script============='
I had the same issue. i tried all commands like adb kill-server then
adb tcpip 5555 then
adb connect :5555 but the issue remain same
the IP address which i used to connect ... showing me message unable to connect .....
what i did is
go to phone's Settings
then About phone
then Status`
then check IP address
Now try to connect phone with that IP address
Note : - The problem is the IP address changed which i used to connect
I'll add my two cents.
For some devices, you can directly connect by the address and port as specified in the Wireless Debugging section e.g 192.155.230.241:43522
use adb connect <IP:PORT>
If not successful, use adb connect <IP:5555>
If still not successful, it probably means you will have to pair your device to your machine via adb first. This usually comes on some devices with above commands but if not then,
use adb pair <IP:PORT>
On Device > Developer Options > Wireless Debugging > select Pair device with pairing code
Enter this pairing code on console and device will pair.
Now use adb connect <IP:PORT>
Also note, You don't need USB debugging on or any cable connections first and TCPIP configuring with this way.
In my case just restarting the device worked. Just try if you are lucky!
[Dec-2022] I suffered from this problem around 2-3 months.
I tried all the cmd way but my device(Android 12) was not connecting wirelessly. As my laptop & mobile was both connected 5 ghz connection of my router.
After switching my mobile to normal 2.4 ghz wifi network. it connected with adb connect {ip-of-device} !!
So, if your wifi network supports both the 2.4 and 5 ghz then try connecting your devices(laptop/mobile) to another combination. Then try to connect with adb connect {ip-of-device}
I am trying to connect my device via WiFi and following the steps mentioned here.
But when I restart adb in different modes like:
1- adb usb, or
2- adb tcpip 5555
the result is like:
* daemon not running. starting it now on port 5037 *
* daemon started successfully *
restarting in TCP mode port: 5555
And it hangs there itself, nothing happens after that.
Is something else needed that I am missing ??
Thanks, if someone read my question and tried for some solution but I found a work-around solution for this:
1. Run the command adb tcpip 5555 and when it hangs, disconnect the USB
2. Connect the USB again, run the command again, now you can see that it proceeds to next input line where you can proceed to adb connect **.**.**.** command to connect to device via tcp.
3. Now, just remove the USB cable and continue using the device.
NOTE: Device and System must be connected to same wireless network.
I want to connect to the Android device using adb over the network. I am familiar with How can I connect to Android with ADB over TCP? and with https://developer.android.com/guide/topics/usb/index.html and follow the guidelines. Specifically, I did the following:
# adb kill-server
# adb tcpip 5555
* daemon not running. starting it now on port 5037 *
* daemon started successfully *
restarting in TCP mode port: 5555
# adb connect 192.168.1.101:5555
unable to connect to 192.168.1.101:5555:5555
Due to the last error, I also tried
# adb connect 192.168.1.101
unable to connect to 192.168.1.101:5555
I also tried to restart the device itself, but it did not help.
Any reason why it does not work?
Update: To clear any doubts, I am sure that this is my device internal IP address.
I've been having the same issue with my unrooted device. And contrary to popular belief it seems that adb tcpip <port> requires either an emulator or a debug build or root privileges; at least according to the source code.
master branch: https://github.com/android/platform_system_core/blob/master/adb/adb.c#L898 look at should_drop_privileges which prevents https://github.com/android/platform_system_core/blob/master/adb/adb.c#L966 adb_main to open a TCP/IP socket connection.
In older branches the logic for identifying the privileges of adbd were in adb_main itself. See: https://github.com/android/platform_system_core/blob/froyo-release/adb/adb.c#L860
So, to further prove that adbd won't enter TCP/IP mode (even though adb tcpip gives out no errors), look at the following:
adb shell getprop | grep 'ro.secure\|debuggable\|qemu', output for my device:
[ro.secure]: [1]
[ro.debuggable]: [0]
This does not meet the conditions of being able to get a secure value of 0 in adbd, since I'm not running an emulator (which needs TCP/IP by default), I'm not running a debuggable build of Android, and I'm not root.
Furthermore if you issue an adb shell netstat command you'll see that there's nobody listening on port 5037 or 5555 or whatever else you supplied to the tcpip command as expected from an adbd running in TCP/IP mode.
Hope this helps, good luck!
The ability to restart adbd using tcpip transport can vary from device to device. Without knowing exactly which device you're using it's very difficult to know the exact cause.
I tested "adb tcpip 5555" on a Galaxy Nexus (takju) running 4.2.1 and found it to work. I also tested on a couple other devices and those did not work.
I managed to get it to work using root access on a Motorola Droid 3. Note that ro.secure=1 and ro.debuggable=0 still. I simply by manually set service.adb.tcp.port" to "5555" as such:
devbox:~/droid3$ adb shell
shell#cdma_solana:/$ getprop | grep 'ro.secure\|debuggable\|qemu'
[ro.secure]: [1]
[ro.debuggable]: [0]
shell#cdma_solana:/$ su -c 'setprop service.adb.tcp.port 5555'
shell#cdma_solana:/$ exit
devbox:~/droid3$ adb tcpip 5555
restarting in TCP mode port: 5555
devbox:~/droid3$ adb connect 172.16.0.14
connected to 172.16.0.14:5555
devbox:~/droid3$ adb -s 172.16.0.14:5555 shell
shell#cdma_solana:/$
Although I specified 5555 when running "adb tcpip" it gets ignored by the device. It seems that this particular device does not have the required access to set the "service.adb.tcp.port" property without root.
Similarly, you can go back to USB as such:
shell#cdma_solana:/$ getprop | grep adb
[persist.service.adb.enable]: [1]
[ro.sys.atvc_allow_all_adb]: [0]
[persist.adb.tcp.port]: []
[init.svc.adbd]: [running]
[service.adb.tcp.port]: [5555]
shell#cdma_solana:/$ su -c 'setprop service.adb.tcp.port ""'
shell#cdma_solana:/$ exit
devbox:~/droid3$ adb -s 172.16.0.14:5555 usb
restarting in USB mode
devbox:~/droid3$ adb shell
shell#cdma_solana:/$
The reasons that this might not work on other devices vary.
On the Galaxy Nexus I tested, the shell user is able to set the "service.adb.tcp.port" property. It's not clear why this differs at this time.
Interestingly it seems the droid3 will not continue to listen on USB if you enable TCPIP. However, the Galaxy Nexus will.
Hope this helps..
PS. See also: How can I connect to Android with ADB over TCP?
I also met same scenario as your, TCPIP setup succeseed, but adb connet failed. I finally found it's my network problem, the ping also failed under that scenairo.
After i made the ping works, the adb connect works as well. So, my suggestion is to check your network environment.
Hi there I know this is an old question but I was having the same problem. I am not sure it is the same case for you but the problem for me was that I was connecting my Android device through a USB expansion, as soon as I connected the Android device directly to the USB port in my MAC it worked.
Just to clarify try to connect the Android device directly to the computer or try switching the USB port.
Trying to configure ADB so that I can debug it via wifi, I have checked on Google but not getting proper resolution.
Tell me what to enter in port address, device ip.
Moreover setprop service.adb.tcp.port command is running when i give space between set and prop, bit confuse...
Seeking for help
I got the following article, and wanted help in the same context.
disconnect device from usb then tell it to listen on 4455
adb tcpip 4455
restarting in TCP mode port: 4455
connect to the device using a specified ip:port. my device is using wifi
adb connect 192.168.1.103:4455
connected to 192.168.1.103:4455
now do normal adb commands over tcp
adb shell
when your done, you can put it back in USB mode
adb usb
restarting in USB mode
Help me
These are commands for the shell of the android device, not for the host system.
Type adb shell to get the device's shell and then enter them. If you get back to the windows shell prompt you are in the wrong place.
However those commands may not be effective on a secured device anyway.
setprop is an Android command and is meant to be used in a terminal after su on the device (you can do adb shell setprop ... but when you adb shell stop adbd you'll loose your device connection). The easier way if already connected via USB is adb tcpip 8600 and then adb connect IP_OF_PHONE:8600 -- but this will only work if adb shell will get you a root prompt (starts with # and not $). Be aware that anyone on your wifi network can access your device!
I'm basically trying to do this:
How can I connect to Android with ADB over TCP?
with the Droid X2.
I have USB Debugging on, and my phone is plugged in via USB.
The IP Address is 10.0.78.33 (I have verified that I can do TCP communication to the phone on that IP, and I can ping it).
I go to the command line and do the following:
>>adb tcpip 5555
restarting in TCP mode port: 5555
>>adb connect 10.0.78.33:5555
unable to connect to 10.0.78.33:5555
Any thoughts on why this doesn't work? Do I need root access in order to do this? I'm trying to avoid rooting the phone.
Thanks!
Step 1 . Go to Androidsdk\platform-tools on PC/Laptop
Step 2 :
Connect your device via USB and run:
adb kill-server
then run
adb tcpip 5555
you will see below message...
daemon not running. starting it now on port 5037 *
daemon started successfully * restarting in TCP mode port: 5555
Step3:
Now open new CMD window,
Go to Androidsdk\platform-tools
Now run
adb connect xx.xx.xx.xx:5555 (xx.xx.xx.xx is device IP)
Step4: Disconnect your device from USB and it will work as if connected from your Android studio.
Symptoms
With my phone, this problem happens a lot. I get these symptoms:
ping x.x.x.x times out
adb connect x.x.x.x times out ("unable to connect")
telnet x.x.x.x 5555 times out
Workaround
I need to disable and re-enable WiFi on my phone before running adb connect on my computer. Then I can both ping, telnet, and adb connect to the phone.
I'm using a Sony Xperia M C1904 running CyanogenMod 12.1.
Your device hasn't to be rooted. I've developed a plugin for IntelliJ/Android Studio to connect your device over wifi pressing just one button. Here is the code and here the plugin ready to be used.
The usage is quite simple. Here you have a gif:
In my case i need pair device with code.
in phone "For developers" -> "Wifi debug" -> "Connect with code"
adb pair x.x.x.x:xxxxx password
adb connect x.x.x.x:xxxxx
Root IS needed to change that system properties. However, it is not needed to start adb over wifi.
You can forward the ports while connected through USB and then tell the adb daemon to listen over a certain frequency:
ADB over wirless
I've encoutered the same problem, and my device was rooted. The problem actually came from adbd Insecure.
If you installed adbd Insecure on your device, it will prevent you from connecting to your device via WiFi. You have to uncheck the "Enable insecure adbd" in the app adbd Insecure.
See FIXED: Can't connect to adb over wifi
The problem with me for my Samsung Tab 1 was an adb process was already running on port 5037 on my Xubuntu 14.04 machine, which I was unaware about until I typed pgrep -l -u username. To fix this, I terminated the adb process using pkill adb, navigated to my platform tools folder and ran adb tcpip 5037 and then connected to my device using the 5037 port number. Boom! Worked like a charm.
Android wifi ADB was earlier working on my IDE but after Updating Android Studio (my current is Android Studio 3.3) it is not working and always prompt as "Unable to connect to device......Same network"
After spending much time i was unbale to resolve the issue.
Then i tried - WIFI ADB ULTIMATE by
https://github.com/huazhouwang/WIFIADB/tree/master/WIFIADBIntelliJPlugin
It worked for me.
I know it's an old thread and OP is asking in very common scenario but I would like to mention what happened with me.
I was able to connect to ADB over wifi through below steps:
connect android phone to computer via USB (critical initial step)
open terminal in android studio & navigate to where the adb is installed
execute command adb tcpip 5555. this will restart the adb in TCP mode port: 5555
execute command adb connect <ip address>
for first time you might need to give access to adb from phone when asked
after connection establishes, you can disconnect the usb cable and you're good to go.
This worked all the time when I'm on my home wifi.
Twist:
I got the error saying failed to connect to '172.16.224.20:5555': Connection refused, when i tried to connect from Starbucks cafe wifi (or any other public wifi).
After some research I realized that
many public wifi has some configuration restrictions which doesn't
allow adb over wifi
.
I couldn't connect adb to my Nexus5 Phone over 5Ghz WLAN but it did work with the slower 2,4 Ghz instantly.
After you run setprop service.adb.tcp.port 5555 and restart adb you won't see the device if you run adb devices on the host.
Instead, you have to run adb connect 10.0.78.33:5555
I hope this will helpful and worked for me
Disconnect phone from studio.
Go to developer options in phone.
Under USB debugging, there is an option to Revoke USB debugging authorisations.
Then click ok.
Then again connect phone to studio via USB.
Then click on connect button in ADB Wifi.
Now you can run and debug apps without USB