Related
I understand we could turn off Wifi through the "adb shell svc wifi disable" command but I don't want to completely turn off Wifi. I want to disconnect from a particular ssid through adb. Is it possible?
Edit: I got a notification saying this question is identified as a dupe of this question: How to turn off Wifi via ADB?. It actually is not. As mentioned clearly in the first paragraph, I don't want to turn off wifi but want to simply disconnect from a particular network. This is like long pressing a network and tapping "Forget network". Essentially I want to simulate a condition of the user moving out of a wifi network without having to turn off wifi.
If you have root access, you can make it by using wpa_cli.
First, you can use the wpa_cli`s list_networks to get the network id of the network that you want to disconnect
$ adb shell
# wpa_cli
> list_networks
**network id** / ssid / bssid / flags
0 001aLinksys14081-2G any [CURRENT]
and then you just need to run the wpa_cli remove_network {network id}, where the {network id} parameter is the one that you got on the list_networks method.
One option is to use cmd wifi. For disconnecting from a Wi-Fi network, you can "forget" it like so:
adb shell cmd wifi list-networks
adb shell cmd wifi forget-network <networkId from list-networks>
You can view the help documentation for cmd wifi with:
adb shell cmd wifi -h
This command did it for me
docker exec -it $container_id /bin/bash -c "cd /root//shared-tools/android-sdk/platform-tools; ./adb shell 'svc wifi disable'"
You cannot. But, this will not be enough to satisfying your question, there is tricky way to connect to "other wifi". (Yes, it is not disconnect)
Install an app, and send command to the app via adb.
See this: https://stackoverflow.com/a/37303412/850347
I already build an app which does so and it's available here: https://github.com/steinwurf/adb-join-wifi
Once the app is installed, a wifi access point can be joined using the following ADB command:
adb shell am start -n com.steinwurf.adbjoinwifi/com.steinwurf.adbjoinwifi.MainActivity -e ssid [SSID] -e password_type [PASSWORD_TYPE] -e password [WIFI PASSWORD]
See this: https://stackoverflow.com/a/37303412/850347
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've already used this commands before to set ADB to listen on TCP/IP, but this time I'm stunned. The problem is that the error it's throwing just makes no sense:
$ adb tcpip 5555
* daemon not running. starting it now on port 5037 *
* daemon started successfully *
error: device not found
In fact even trying to put it in USB mode doesn't work either, with same error:
$ adb usb
error: device not found
Just for the info, the adb help says that:
adb usb - restarts the adbd daemon listening on USB
adb tcpip <port> - restarts the adbd daemon listening on TCP on the specified port
I've made no changes in Android SDK (no updates). Any help would be appreciated.
The issue was that I had to have an Android device connected (same device or another device) by USB to be able to execute
$ adb tcpip 5555
restarting in TCP mode port: 5555
Then I can just unplug this USB device and connect to the other devices on the LAN over TCP.
Just makes no sense at all.
Ensure your device is set for Debugging under Developer Tools, then on your host computer's command-line, type:
$ adb tcpip 5555 - restarts the adbd daemon listening on TCP on the specified port (typically 5555)
restarting in TCP mode port: 5555
If you get "error: device not found", you need to temporarily connect an Android by USB cable. (This doesn't even need to be the same device, and doesn't need to remain connected)
Then, connect to the Android device by IP address. (Ensure your Android is connected to your local network then to find the IP address, click on the wifi network connection to see connection details.)
$ adb connect 192.168.0.10 - connects over network to remote device IP (replace 192.168.0.10 with your Android device's IP address)
connected to 192.168.0.10:5555
Depending on your connection, this could take a minute or so to establish the first time.
To switch back to your USB connection, type:
$ adb usb - restarts the adbd daemon listening on USB
Additional Notes:
You do not need root access for this to work.
You may need to open port (5555) in your firewall.
You can use "ping " to
ensure your host can find the device on the network
What you probably want is:
connect <host>[:<port>] - connect to a device via TCP/IP
Port 5555 is used by default if no port number is specified.
so:
$ adb connect 192.168.1.38
adb usb and adb tcpip <port> commands control the transport mode of the adbd daemon running on the device. In order to change the mode the current transport has to be functional. In your case the adbd is running in USB mode - so you have to connect the USB cable in order for the mode change request to reach the deamon.
If you want to avoid having to connect USB just to enable the TCPIP transport - you can either change the default settings or switch it manually from a terminal emulator on the device itself.
I also encountered this problem and tried to solve them in a week. Finally it is solved within minutes when I change the setting in my device to allow the debugging when charging. I also ensure that the allow usb debugging enabled because sometimes when you choose to allow debugging when charging, the allow usb debugging will be disabled.
after that, I try the adb tcpip 5555 again and voila!!! no more no emulators... kinda message. I then connect using adb connect 'ip address':5555 and it works like charm.
After connect phone with usb, choose option at phone "charging only".
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