The following scenario:
Windows 10 machine with adb version 1.0.40
rooted Android phones, anything from android 5 to 8
An application does the following on each found adb device:
a reverse connection is set up on each phone using adb -s xxx reverse tcp:8080 tcp:8080
using adb -s xxx reverse --list is checked if the reverse is set up correctly
The android application opens a WebSocket connection to a running WS server on the PC
On Android 6 and higher, the --list command returns (reverse) tcp:8080 tcp:8080, which is correct. The android application opens the WebSocket connection properly.
Problem:
On any Android 5 phone, the following happens:
opening the reverse works properly.
Android is opening the WS connection to the PC
The command adb -s xxx reverse --list is returning the error error: protocol fault (couldn't read status length): No error
This causes the phone to be disconnected and reconnected again (seeing the windows popup of the connected device)
This, of course, also kills the WebSocket connection
Now my questions:
I couldn't find the above error message, even with googling.
Shouldn't it at least appear somewhere in some Adb source code?
Is there any component which does the Adb stuff on Android, that
could be updated somehow, or is it tied to the android version?
Could this check (adb reverse --list) also done on the adb shell?
Any other ideas how to do the check without that command or make the
command work on Android 5?
Related
I genymotion emulator and my phone connected , I want to run and debug my application over wifi , I found the instruction to do so but I get this error when I enter this code :
adb tcpip 5555
I get this error :
error: more than one device/emulator
How can I make my device as default or something like that to solve this problem ?
You can send commands to a specific device, according to docs:
$ adb devices
List of devices attached
emulator-5554 device
emulator-5555 device
$ adb -s emulator-5555 do_your_command
Also, if only one is emulator or a real device you can just attach -e or -d and send the command to it:
If you have multiple devices available, but only one is an emulator, use the -e option to send commands to the emulator. Likewise, if there are multiple devices but only one hardware device attached, use the -d option to send commands to the hardware device.
Do following thing which will help you,
You getting the message just because you are connected more than one device.
Run commands
adb devices
after the fire above command, you get the list of the device, From the list select your device id which not emulator
and fire following command
adb -s f725aa8b7ce4(deviceId) tcpip 5555
and after this fire
adb connect yourIp 5555
I was struggling with same issue since months, later while testing in postman I got know that "Appium inspector" is the main reason for this issue. As it creates new session Id and interrupt the running framework server.
Hence, adb kill-server adb start-server resolves the issue as it actually kill the session ID created by Appium inspector and starts new server.
I am trying to connect to an Android device connected to my laptop while developing and writing code via Remote Desktop and VPN on my work machine.
What I would like to do is to build on the remote machine and deploy to android phone via VPN connection to android device connected on the laptop via USB.
I tried following another post but was unable to get it to work.
Here is what I did so far.
Forked ADB server on laptop:
adb -a -P 5037 fork-server server&
Connected to my server from desktop:
adb connect mylaptopname:5038
UPDATE
I also tried following instructions from this post I also do not see my devices.
I run this on the laptop adb -a -P <PORT_NUMBER> nodaemon server and then run this on the desktop where I develop adb -H <REMOTE_IP> -P <PORT_NUMBER> devices I still do not see the device.
I get this back: List of devices attached and nothing else, indicating it does not see any devices.
The connection was successful but my desktop still does not see the phone.
I am trying to use ADB on an Android device itself, so without any host computer. This was working perfectly a couple of days ago, but it suddenly stopped working. As far as I know nothing changed since then (e.g. no apps (un)installed). I could use adb backup -f /sdcard/backup.ab <package-name> in a terminal emulator and it would start to backup that package. When I try that now, it returns adb: unable to connect for backup. Investigating using adb devices returns an empty list. I never bothered to check the devices previously, I just went straight to my adb command, because everything was working.
This was on an HTC Desire running Android 4.4.2, ADB version 1.0.31.
Using ADB from my PC with this phone is working perfectly, but this is not what I want.
What I have tried
I have tried to perform the same actions on different devices (Asus PadFone 2 on 4.4.2, Samsung Galaxy Note GT-N7000 on 4.4.2, Sony Xperia S on 4.1.2.) but adb devices returns an empty list on all of them. I am starting to wonder why this has worked on my HTC Desire in the first place.
Searching Google and Stack Overflow, but most (if not all) results refer to a driver problem or any other problem involving a host computer.
adb kill-server + adb start-server about a hundred times, as well as stop adbd + start adbd.
Turning 'USB Debugging' off and on in the Settings, as well as revoking access to previously authorized computers. (However, in the working situation, I never got any RSA key verification prompt.)
adb -a devices -> empty list.
adb usb -> error: device not found.
Trying to restart adb(d) in TCP mode is unsuccessful (even though this was not necessary in the working situation). adb tcpip 5555 returns error: device not found.
getprop returns no entry named service.adb.tcp.port and setprop service.adb.tcp.port 5555 silently fails. (Checking afterwards using getprop service.adb.tcp.port returns nothing. Doesn't this need root?)
adb connect localhost returns unable to connect to localhost:5555.
When the daemon starts, it starts on port 5038 (when using ADB from my PC it starts on 5037). adb connect localhost:5038 returns connected to localhost:5038. However adb devices still returns an empty list, and adb backup returns adb: unable to connect for backup. Furthermore adb shell returns error: device not found and adb get-state returns unknown. So no success here either.
Finding my local ip using getprop dhcp.wlan0.ipaddress (returns 192.168.1.xx) and then adb connect 192.168.1.xx returns unable to connect to :5555. adb connect 192.168.1.xx:5038 -> unable to connect to :5038. Using ADBHOST=192.168.1.xx adb start-server has no effect on these outcomes.
One of the few search results that was actually somewhat relevant is this thread on the AOSP Issue Tracker. Yet, it describes a problem where, after using setprop service.adb.tcp.port 5555, adb devices at least shows a device, however offline (namely localhost:5555 offline). Somewhat near the end of the thread a solution is reached, which involves changing the $HOME directory so as to change where the RSA keys are saved, e.g. HOME=/sdcard. It is then necessary to append the public key to /data/misc/adb/adb_keys using cat /sdcard/.android/adbkey.pub >> /data/misc/adb/adb_keys. However, I presume this needs root? Also, all of this was not necessary in the working situation so I doubt the solution to my problem is to be found in this direction. This article, derived from the thread at AOSP's Issue Tracker, does not speak of appending the public key. However, the approach mentioned is unsuccessful.
netstat returns (among others):
Proto: tcp
Recv-Q: 0
Send-Q: 0
Local Address: 127.0.0.1:5038
Foreign Address: 0.0.0.0:*
State: LISTEN
ps shows an /sbin/adbd process as well as an adb process:
USER: shell PID: 92 PPID: 1 VSIZE: 3624 RSS: 264 WCHAN: ffffffff PC: 00000000 S NAME: /sbin/adbd
USER: u0_a57 PID: 9754 PPID: 1 VSIZE: 3016 RSS: 988 WCHAN: ffffffff PC: 4014f768 S NAME: adb
(Commands executed from the terminal are executed as USER: u0_a57.)
I guess that's pretty much it.
I am looking for a solution where no root is needed, as it was not needed when I had it working before.
I hope my situation and question is clear. Please let me know if my question needs improving, as this is my first time posting on Stack Overflow.
Hopefully someone can help me with this. Thanks in advance!
I believe your device might have rebooted. To initially get your phone into tcp, you must have ran adb tcpip 5555 from a computer. But that doesn't last forever. If your phone gets rebooted, then you will have to run adb tcpip 5555 from a computer again.
I am not sure what you meant when you said:
Trying to restart adb(d) in TCP mode is unsuccessful (even though this was not necessary in the working situation). adb tcpip 5555 returns error: device not found.
Did you run that from a computer? If it was from a computer then I'm not sure what the problem is there. But if it was from the phone, then it can't find the device to change to tcp.
To fix this, adb tcpip 5555 from a computer should work.
I would like to run automatized test on different Genymotion devices in the same time. For this I have to give seperate port numbers for each device.
Is it possible?
From the Genymotion Launcher, you are able to start multiple VMs. Although these each will have the same default port (5555), they will get different IP addresses from the VirtualBox host-only adapter. For example, I just launched two Genymotion machines and now adb devices shows:
$ adb devices
List of devices attached
192.168.56.101:5555 device
192.168.56.102:5555 device
$
Each can be addressed separately by specifying IP address and port in your TCP/IP socket program, or by using adb -s if you're doing manual command line work or writing scripts. I won't go into socket programming here, but here's a quick example of selective access using adb to see if the Location service is running on the second device:
$ adb -s 192.168.56.102:5555 shell service check location
Service location: found
$
I am a budding android developer and if there is no easy way of configuring the adb server to run on another port then the inflexibility of the tools will force me to quit android app development.
A web search did not return any solutions.
I also searched for '5037' in all files in android sdk directory but did not find a setting there.
Use the environment variable ANDROID_ADB_SERVER_PORT to select the port.
The following works under bash:
$ export ANDROID_ADB_SERVER_PORT=12345
$ adb start-server
* daemon not running. starting it now on port 12345 *
* daemon started successfully *
$ adb devices
List of devices attached
TA2070M5O6 device
$ ANDROID_ADB_SERVER_PORT=6789 adb devices
* daemon not running. starting it now on port 6789 *
* daemon started successfully *
List of devices attached
In another terminal I ran:
$ ANDROID_ADB_SERVER_PORT=6789 emulator ...
Back to original terminal:
$ ANDROID_ADB_SERVER_PORT=6789 adb devices
List of devices attached
emulator-5554 device
$ adb devices # ANDROID_ADB_SERVER_PORT was exported as 12345
List of devices attached
TA2070M5O6 device
I found this via the Jenkins Android Emulator Plugin as I noticed it was running adb on a different port.
With the latest adb version,
Use option -P (Note: Caps P)to start adb server in a specific port.
For Example, Try
$adb -P 5038 start-server
It will list the devices attached to this specific adb server. If the adb server is not running then it will start a new adb server with the given port number.
Hope it helps someone reading this post.
Thanks.
In Windows, go to Environment Variables – Add a new one called ANDROID_ADB_SERVER_PORT
and set it to whatever you want, I've set to 5038.
Should look like this:
Solved it for me.
There is another variable that supports this for connecting to a different machine's adb:
ADB_SERVER_SOCKET=tcp:some.other.host:1234 adb devices
To use it, you need to start adb on the other host with -a and probably background it too:
( adb -a -P 1234 nodaemon server & ) &