Android adb wireless debugging with USB accessory - android

I have adb wireless connection working for debuging applications in eclipse, but I am having an issue with an application that is using the USB cable to attach to an accessory.
The application is designed to start when the accessory is plugged in, SO I establish my ADB connenction and then run debug on eclipse, code loads etc.., now when I plug the accessory in the app starts and runs but loses communication to eclipse. So I can't debug!

In the command prompt just run adb connect <device ip>:5555 again after the tablet is plugged into the FT311 (I am assuming it is the FT311 from your other question). It will then reconnect and then run adb logcat again and done.

That is only a partial solution. Yes, you can reestablish the connection over WiFi (which works great, BTW) but the moment you disconnect or reconnect the USB cable, you'll lose the association with ADB again - even though it's running over WiFi and should have no dependency upon USB at all.
So beware, this works but will not solve the problem if, for example, you're trying to debug anything associated with USB attach/detach Intents.

USB host and accessory overview in Android official developer documentation here REMIND US OF THIS:
Debug considerations
When debugging applications that use USB accessory or host features, you most likely will have USB hardware connected to your Android-powered device. This will prevent you from having an adb connection to the Android-powered device via USB. You can still access adb over a network connection. To enable adb over a network connection:
Connect the Android-powered device via USB to your computer.
From your SDK platform-tools/ directory, enter adb tcpip 5555 at the command prompt.
Enter adb connect <device-ip-address>:5555 You should now be connected to the Android-powered device and can issue the usual adb commands like adb logcat.
To set your device to listen on USB, enter adb usb.
Remember:The Android official documentation will give you better basic understanding of the Android,not sometimes,but ALMOST everytime.

Related

No connection could be made because the target machine actively refused it. (10061)

I have problems trying to do wireless debugging.
I followed this instruction: https://developer.android.com/studio/command-line/adb#wireless
And it seems that I cannot connect to my phone at step 7 of the article adb connect device_ip_address.
It said cannot connect to 192.168.1.35:5555: No connection could be made because the target machine actively refused it. (10061)
I tried searching for the solution in stackoverflow but the answers do not suit my situation. They said to make sure that I connect to the same network and I'm pretty sure I am connected to the same network. I see my phone is connected to wifi name "Chor" And PC is also connected to the same name. I can even ping phone IP in the command prompt and receive a good response.
Any clues about what could be the issue?
The phone I use is Huawei P30 Lite.
I'm using Windows 10.
that Occurs due to
device is Restarted
device is connected to another computer or computer is debugging another device
turn offing the developer options of device
Follow those Steps to resolve that problem,
Connect your device to PC by USB cable to pc(one time requirement) and and turn on usb debugging it will connect successfully, allow for connection in device for promoted message.
2)then type this Command in terminal "adb tcpip 5555"
now remove the USB cable and connect device with pc with wifi
now type this command "adb connect <your_ip>"
you're all done !!
I have accidentally found the solution now!
It seems to be a phone issue (specifically Huawei phone).
It keeps turning off USB debugging mode by itself so what I had to do was to prevent it from turning off USB debugging mode.
I am not clearly sure of what is the exact step that fixed the issue but here's everything I did in Developer options:
Revoke USB debugging authorizations
Allow ADB debugging in charge only mode (I think this fixed the issue)
Turn off Always prompt when connecting to USB
Seems like there are some bugs with authorization conditions across different manufacturers. To get your target device to trust your computer, you need to go through more than just approving the computer's MAC address.
After some modifications of #off99555's answer, this is the solution for OnePlus 7 T/Pro devices on OxygenOS 10 (Android 10.x). Might be device manufacturer specific:
Revoke USB debugging authorizations
Connect target device via USB
Change USB usage mode to "File Transfer"
Run 'adb connect 192.168.x.x:5555'
The target device should recognize your computer now, and you can unplug USB and use ADB wireless now. Note that if you revoke USB auth in the future, you will have go through these steps again.
I ran into this error message when attempting to debug my Samsung Galaxy watch and it turns out that the Samsung Galaxy watches run on the Tizen OS and are not meant to be connected to Android Studio via adb. In order to develop apps for these devices, you will need to use Tizen Studio and connect to your device via sdb.
I'm facing the same issue then I'm restart everything like Phone, Android Studio/VS Code, and restart Computer. then solved.
Some of the commands you can try.
adb tcpip 4568
adb connect <Your device IP>:4568
adb disconnect
adb kill-server
in my case it showed wrong device ip when i ran ipconfig command. so check your device ip and try again
check your wifi debugging ip address
developer option -> wifi debugging
As other mentioned about the process you should first clean the path for connection. But try these two important points
1- Change adb to .\adb
.\adb kill-server
.\adb usb
.\adb tcpip 5555
.\adb connect 192.168.1.34:5555
2- Just you can keep one IP and for the next must clean the path!
Points:
1- As you know, we can set the IP address for a real phone in Static
2- If use a real phone by android 11, need to turn on Wireless debugging, then find the IP & Port
Solved:-
Just once connect your mobile with USB and allow the permission pop-up on the mobile screen, and then try to connect on wifi, it will connect.
Make sure you are using a cable that can transfer data, and that the device appears in the devices list when the cable is connected.
For device list run command:
adb devices
While the device is still connected enter the connecting command, with the IP address from the device wifi settings.
adb connect ip_address

Android Studio wireless ADB error (10061) (TV)

I see lots of posts everywhere showing how to connect to Android device using adb connect <ip> but in my case it's not working...
unable to connect to <ip addr>:5555: cannot connect to <ip addr>:5555: No connection could be made because the target machine actively refused it. (10061)
Developer mode is OK;
USB debugging is OK;
Both computer and device are connected to same network;
There is no USB port to plug (Android TV)
Before I was using another brand and it worked fine, I could connect it over wifi no problem, but after I switched to this brand called MXQ I can't manage to work it anymore.
Any ideas?
Thanks.
After long try I could finally find the solution. If anyone needs it, here is what I did.
On this brand (MXQ) there is two ways to access settings. The traditional Android way and:
Open Apps on the device and locate the App called settings
Enable USB debugging
After that you will be able to connect via USB (type A) available on the device
Connect to Android Studio just like usual.
*You will need a USB type A to A to do that..
** Make sure your USB cable has data wires (check usb)
You have to do following steps (In most cases this happen in Huawei devices)
Revoke USB debugging authorizations Allow ADB debugging in charge
only mode (I think this fixed the issue) Turn off Always prompt when
connecting to USB
Main steps:
open Cmd,
adb kill-server
Connect your phone with usb cable and enable debugging and select file transfer (MTP)
adb tcpip 5555 (Port Number)
Disconnect device unplug usb cable
adb connect YourDeviceIpAddress:5555

Is there a way to disconnect USB device from ADB?

I have a lot of scripts that use ADB to debug Android applications via Wi-Fi with emulators. The problem appears when I charge my Android phone via USB from my computer: ADB sees it and sends commands to my phone instead of emulator.
Is there a way to disconnect ADB from phone that charges via USB? I know I can send commands to emulators only via -e switch, as well as send them to specific device via -s switch. However, it is not OK for me, because I have to rewrite a lot of scripts to add more arguments if I want to implement this device selection feature. I don't need workarounds, I just curious does Google force ADB to debug any phone connected via USB that has USB debugging enabled in settings, or it is possible to remove specific USB connected phone from devices list on ADB side?
When I run adb disconnect, USB device remains connected.
USB connection for internal storage and adb connection for debugging are two separate things.
To disable adb - you can use adb disconnect or simply turn off usb debugging under developer options.
For disconnecting usb connection for internal storage certain ROMS have the option. e.g. CM 13 that i have at the moment allows connecting USB just for charging. Generally on other ROMS and Stock ROM I've not seen this option but you can try this. -> If you connect your device via USB while locked the internal storage will not be available unless you unlock the device once.
ADB doesn't support disconnecting a USB connection now(version 1.0.39).
"adb disconnect" can only disconnect a TCP connection set up by "adb connect", it can not disconnect a USB connection.
You can "disconnect" a connection by using push and reconnect commands as a workaround:
1.push a file to phone
adb -s SERIAL push somefile /data/local/tmp
2.reconnect while push is still in progress
adb -s SERIAL reconnect
SERIAL means serial number listed in the output of 'adb devices' command.
Repeat step 1 and 2, after a while, you can find this device is in offline state from output of "adb devices".
No adb command can operate this offline device until you kill-server and start-server.
just use adb kill-server to kill the connection
adb disconnect also works
On the device itself go to Developer options. There is a "USB debugging" switch. You can simply switch off "USB debugging" while you don't need the device to be seen by adb.
Alternatively (if, say, you want "Trust this device?" window appear on the device again) you can tap "Revoke USB debugging authorizations" option (also in Developer options. Tapping it will revoke all authorizations, including the one for your PC. Doing that will also restrict access from adb. To re-enable adb connection for the device, disable and re-enable the "USB debugging" switch. That will force "Trust this device?" window appear on the mobile device (should be unlocked for that perpose). Say "ok" and you should be able to connect via adb again.
Update your scripts to use the the id of the emulator so that you can direct adb commands to emulator:
adb -s{serial_number}
Ex:
adb -s emulator-5556 install myApp.apk
If you have only one emulator you can also use '-e' to direct adb commands to emulator.
adb -e install myApp.apk
The same can be done to force commands to your mobile, using '-d'.

adb device offline with ADB wireless

For some reasons, my phone does not work anymore with cable.
I saw on the Internet that it is possible to connect adb to the via Wifi, however I tried it and I get this:
adb devices
List of devices attached
192.168.1.2:5555 offline
I search this on Google and it seems that it is related to Android 4.2.2.
And indeed, my device is running Android 4.2.2.
I didn't find any answers on Google for my problem since it is always with a cable, mine is on Wifi...
Any idea how to solve this?
For me the complete steps that worked were :
Settings -> Developer options -> Revoke USB debugging authorizations (clear the list of authorized PCs).
Set USB Debugging OFF.
In Terminal write : adb kill-server
Then : adb start-server
Then : adb connect xx.xx.xx.xx:5555 (the devices ip), it should say unable to connect.
Now turn ON USB debugging again and type the adb connect xx.xx.xx.xx:5555 again.
It should now ask for authorization and you are back online without
needing to connect cable to USB, only wifi used.
run adb kill-server, then try to connect wirelessly again. It worked for me.
I could not find exact solution for this problem too.
Best way worked for me was disconnecting device from wifi, then try to connect while device is not connected to Wifi like:
adb connect 192.168.55.3:5555
this causes adb waiting for connection. immediately connect device to wifi and adb will detect device and connect again.
hope this helps.
Disconnect adb over wifi, connect your phone with a USB-cable to your pc. It will ask you on your phone is you want to allow the connection. Tick always allow. You will only get this when you connect with USB and have to do this only once, you can use over wifi afterwards.
Don't get the pop-up? Try the answers on google over a cable, since you need to do this first.
It seems you want authenticate adb over wifi.If you had your device rooted,you can try this way.
Copy ~/.android/adb_key.pub to your android device,and rename it to adb_keys
Move it to your /data/misc/adb/
Reboot your android,then reconnect over wifi.
For the first time in debug mode, you need to Authorize your phone with the PC, and that requires the USB cable. After that you can use Debug over WIFI.
If you want to force your phone to show the Authorization message box, simply delete the below file.
/data/misc/adb/adb_key
In android studio go to Preferences->Plugins
Download and install this plugin
ADB WIFI Connect
, restart Android Studio
Connect phone via USB
In android terminal use command: adb devicesyou should get visible device connected via USB:
List of devices attached
988a57334e57365058 device
Click on plugin icon in android studio AndroidWiFiADB
If phone get connected properly via WiFI, you see in event log:
12:41 Android WiFi ADB: Device 'ModelOfYourPhone' connected.
In android terminal use command: adb devices use should get
List of devices attached
988a57334e57365058 device
192.168.60.101:5555 device
Disconnect USB cable and re-check again adb devices, should remain only device connected via wifi:
List of devices attached
192.168.60.101:5555 device
Try disconnecting your device with:
abd disconnect <IP/TCP>:<port>
Then restart the WiFi connection of your device, and reconnect your device with:
abd connect <IP/TCP>:<port>
That may fix it; it worked for me.
For me, the important part turned out to be the following line adb tcpip 5555 together with using the port in the IP of my phone like so: adb connect 192.168.1.87:5555 (only using one of them, did not work, i.e: writing the second alone didn't work, writing the first and then excluding the port in the IP also didn't work). The adb tcpip 5555 line is not mentioned anywhere here. So, for me, the PORT needed to be both manually set and used in the connect line!
These are the events of my command line in Windows PowerShell Admin to demonstrate (Wifi on and debug mode on and confirmed permission when the popup came):
notice that the connection first failed, then it said it was connected which is weird behavior to begin with (no matter what, it always failed once and "succeeded" once), and in both instances, the device showed as offline. The disconnect commands also confirm that its 110% offline
PS C:\WINDOWS\system32> adb kill-server
PS C:\WINDOWS\system32> adb start-server
error: protocol fault (couldn't read status): Connection reset by peer
PS C:\WINDOWS\system32> adb start-server
* daemon not running; starting now at tcp:5037
* daemon started successfully
PS C:\WINDOWS\system32> adb connect 192.168.1.87:5555
failed to connect to 192.168.1.87:5555
PS C:\WINDOWS\system32> adb devices
List of devices attached
220947272e047ece device
192.168.1.87:5555 offline
PS C:\WINDOWS\system32> adb connect 192.168.1.87:5555
already connected to 192.168.1.87:5555
PS C:\WINDOWS\system32> adb devices
List of devices attached
220947272e047ece device
192.168.1.87:5555 offline
PS C:\WINDOWS\system32> adb disconnect 192.168.1.87:5555
error: no such device '192.168.1.87:5555'
PS C:\WINDOWS\system32> adb disconnect 192.168.1.87:5555
error: no such device '192.168.1.87:5555'
PS C:\WINDOWS\system32> adb tcpip 5555
restarting in TCP mode port: 5555
PS C:\WINDOWS\system32> adb disconnect 192.168.1.87:5555
error: no such device '192.168.1.87:5555'
PS C:\WINDOWS\system32> adb connect 192.168.1.87:5555
connected to 192.168.1.87:5555
PS C:\WINDOWS\system32> adb devices
List of devices attached
220947272e047ece device
192.168.1.87:5555 device
As soon as I added the adb tcpip 5555 command and it restarted in TCP mode port: 5555 the adb connect 192.168.1.87:5555 command worked!
Make sure that pc is authorized in the device by going to Developer options -> Revoke USB debugging authorisations and then trying to connect via USB. After accepting the PC, disconnect the cable and connect through wifi.
adb kill-server
adb run-server
adb connect IP:5555
Although in my case, when I tried to connect it failed at first and second try it said already connected.
I disconnected from the device and connected again and it solved.
adb disconnect ip:5555
adb connect ip:5555
I solve this problem for huawei P10.
its about phone's developer settings => find usb developer settings, and under usb developer setting there is a "adb debugging in charging mode..." enable it. My problem solved with this way. Hope yours too....
My solution steps:
Turn Off WiFi and Turn it back On again.
Settings -> Developer options -> Revoke USB debugging authorizations.
Settings -> Developer options -> Turn Off ADB over network and turn it back On again.
adb kill-server
adb start-server
adb connect xx.xx.xx.xx:5555
Note: Step 3 was the key for me. don't forget it.
In simple cases it will start after Enabling USB debugging
For complexities you need to delete the
adbkey
file from
C/.android and then running following commands in command prompt
adb kill-server
adb start-server
adb devices
Note that wireless adb connectivity in Android 6.0.0 is broken. Updating to 6.0.1 fixes the issue.
https://stackoverflow.com/a/34530543/1123355
In Windows, if you are using system-wide proxy software like Proxifier, you need to add adb.exe to the ingore list or direct-mode list. In my case, using Proxifier will make adb able to connect to any IP address even when the phone is not connected to the WiFi, and this leads to device offline.
I know its late to answer but I believe this is the exact answer:
go to WIFI setting on your device and "set a new IP" in your network IP range an reconnect.
Conflicting ADB connections can cause this issue as well:
Windows Host with Docker to Hyper-V Android x86 emulator
I didn't see this answer here yet so for those attempting something similar, the issue I had was that the local Windows Host ADB process had already acquired the adb connection during start up (adb server start).
By simply running: adb disconnect <Device/Android x86 Hyper-V ip>:5555
on host machine
Running adb connect <Device/Android x86 Hyper-V ip>:5555 on the Docker container was able to successfully acquire the remote device (aka Android x86 Hyper-V)
IMPORTANT!!! Until you disconnect Docker (or whatever), your host machine (or any others) will not be able to connect, apparently only one ADB connection at a time is allowed.
I didn't need to do anything else listed above. Hope this helps others.
Just turn off your Proxifier or something else like this.
Socks5 works fine
Watever! I'm always using these steps to connect ADB Wifi with android studio
STEP-1:
1. Go to Android studio->Settings-> Plugins -> Search ADB WIFI
2. Install the pluging and restart android studio
STEP-2:
1. Find the location of SDK Manager For ex for my computer
Copy the whole location
Now open Terminal in Android studio itself( This will show in right bottom corner).
type cd YOUR_SDK_LOCATION
type cd platform-tools
Now type adb tcpip 5555
FOR NEXT STEP YOU MUST CONNECT YOUR MOBILE AND LAPTOP WITH SAME WIFI
type adb connect 192.168.6.100:5555 in terminal (Here 192.168.6.100 is your mobile IP Address)
now the message will show like this 'connected to 192.
168.6.100:5555'
STEP -3 :
1.Go to Android studio->Tools->ADB WIFI-> ADB Restart
1.Go to Android studio->Tools->ADB WIFI-> ADB USB to WIFI
Like below
That's it .
In My case my wifi network is not same thats why i am not getting connected with the device.
There is very easy and helpful plugin for this purpose Android Wifi ADB
How to Connect using plugin:
connect device using cable
click on Android wifi adb icon
disconnect your USB connection now your device is connected over wifi.
Enjoy Happy debugging.
adb reconnect offline
adb connect [ip]:[port] (for exemple adb connect 192.168.8.100:44
While all tips with killing ADB server helped me many times, now I got the message:
cannot connect to <IP>:<port>: No connection could be made because the target machine actively refused it. (10061)
It was possible to attach the device only while it was connected with USB, and after disconnecting cable it appeared as offline at the attached devices list.
I have just solved my problem by changing the USB configuration:
Developer options > Select USB Configuration: MTP (Media Transfer Protocol)
PTP (Picture Transfer Protocol) works as well.
Screenshot
I hope it will help.
I have this problem just now. Note that my case is special, the usb has been disabled for security concerns. Reboot not working. This is not ip problem since ping is working and nmap shows 5555 port is open. Also since I will not able to connect if port is wrong, so nothing to do with port.
There are 4 reasons:
Because another pc in the local network already connected, so the other guy have to adb disconnect first, then I can do adb disconnect and adb connect <ip>, since only one person can connect at the same time.
A hotspot ssid name might consists of multiple bssids in (especially you're in office) local network, so you need to ensure your pc try all the hotspot bssids which match the android connected hotspot bssid. Note that I noticed it's not always the case (Now I tried different bssids still success), but it did solved before.
Ensure the port 5555 is open correctly. Even though there are many ways, but you can download this app to open port 5555.
And I just encounter a weird case, client A connect just fine. But then client B turn on wifi and attempt to connect but failed. Then this failure causes original client A no longer able to connect. Reboot device/adb disconnect/adb kill-server doesn't help, and confirmed the ip is same(tested by turn off/on device and observe the ping). I make a joke about client B wifi still turn on may interfere the device wifi. Then I realized Client B disconnect/kill-server is not enough, client B also need turn off wifi to make client A connect. And it did.
Try,
adb disconnect <your_ip_address>:port_number or adb disconnect
eg.
adb disconnect 192.168.1.2:5555
Or
adb disconnect
The difference is that first one will disconnect only the required device, the second one will disconnect all the devices.
The benefit of using this command is that you don't have to kill and restart the server. Killing and restarting the server requires your device to be plugged in to your computer which is most irritating process.
For me the reason is GLOBAL PROXY (A country without international internet). Adb try to connect my device through proxy server.

Debugging in Android device over wifi without rooting [duplicate]

This question already has answers here:
Run/install/debug Android applications over Wi-Fi?
(41 answers)
Closed 6 years ago.
Is there any possible way to debug or run android apps from eclipse to my Sony Tablet S over wifi rather than USB without rooting the device?
There are ways to do it, if the device is rooted. However, I am seeking the solution in a device that is not rooted.
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 like
adb shell
when your done, you can put it back in USB mode
adb usb
restarting in USB mode
After a bit of dabbling with testing I successfully managed to connect a Sony Tablet S over ADB following this procedure, when both the computer and the tablet were on the same wifi network. I used an Xperia T as a tethering point between a laptop and the Tablet S. I followed the same procedure on an Xperia Tablet S and an Xperia S as well.
Connect the Sony Tablet S through USB to a computer, make sure you have ADB debugging enabled on the tablet.
On the computer, execute "adb devices", verifying the tablet is showing up in the list of available devices.
Execute "adb tcpip [port]" while the tablet is connected to the computer, verifying you get a response "restarting in TCP mode port: [port]"
Disconnect from the device from the computer it was connected to.
From a host located on the same wifi network, execute "adb connect [ip to device]:[port]", verifying you get a response "connected to [ip to device]:[port]"
In the end I launched Eclipse, created a test project and tried launching the project. The project installed and launched automatically from Eclipse. I also tested this for debugging and that worked equally well.
Finally After lots of search, here is the consolidated, short tutorial about "Wireless Debugging with Android without rooting" your android phone.
Steps:
Make sure your Phone and your PC/Laptop is connected in the same network.
Find your Android Device's IP Address: Go to Settings > About Phone > Status. Note down it.
Ping Test: Lets first check if your phone is accessible from your PC/Laptop to do this ping your Android Device and check its response. See Notes if ping is unsuccessful.
e.g: ping 192.168.1.55
Connect your Android Device Via USB in USB Debugging Mode.
Open command prompt and cd into <Android SDK Folder>\platform-tools directory and run the following commands.
adb tcpip 5555
adb connect DEVICE_IP_ADDRESS_HERE:5555
If you want to switch back to USB mode, use the following command.
adb -s DEVICE_IP_ADDRESS_HERE:5555
Disconnect Android Device from USB. If everything is fine, you can Wirelessly debug your Android Apps!
Notes:
If ping is unsuccessful, Make sure Wireless (WiFi) devices and wired devices are not isolated. If Isolated, you need to disable isolation. Router Mfgrs calls it as AP Isolation. There will be a setting in Router's Wireless Configuration page. I have D-Link Router, I unchecked the Enable MultiAP Isolation setting in Wireless Basic Setup Page.
I personally felt this method of connecting is taking more time.. so, I configured my android device so it uses static IP like 192.168.1.55 to connect to my router and I made a windows batch file like below,
#echo off
cd C:\AndroidSDK\platform-tools\
echo make sure your your Phone is connected in USB Debugging Mode.
pause
adb kill-server
adb tcpip 5555
adb connect 192.168.1.55
pause
so, every time I have just need to plug in my device, and double click the batch file and all done automatic :P !
(No root required) There is one best, easy and with UI method for Android Studio
IntelliJ and Android Studio plugin created to quickly connect your Android device over WiFi to install, run and debug your applications without a USB connected. Press one button and forget about your USB cable.
just install plugin Android WiFi ADB
Download and install Android WiFi ADB directly from
Intellij / Android Studio: Preferences/Settings->Plugins->Browse Repositories
.
Remember! for first time to initialize the device you must have to connect using usb
Alternatively, you can download the plugin from the JetBrains plugin site and install it manually in: Preferences/Settings->Plugins->Install plugin from disk.
for more information read here https://github.com/pedrovgs/AndroidWiFiADB

Categories

Resources