I have two smart phones (ZTEV788d, system Android 2.3.6) connected to a computer (Ubuntu 11.10) at the same time, using command: adb devices
I got this:
List of devices attached
P753A12D device
P753A12D device
The serial numbers are the same!
I wrote an application in the computer side to communicate with these two phones, for example install app and push files.
I used these commands:
adb -s P753A12D install XXX.apk
adb -s P753A12D push XXX /sdcard
Now these two phones have the same serial no (P753A12D
), when I run these commands I get this error:
error:more than one device
So, my questions are:
- Is that normal that two phones to have the same serial no?
- Can I change the serial no? if yes, how?
- Is there any way to run these install, push commands successfully even if the serial no are the same?
BTW, the WiFi/3G network will be turned off when I'll run the test.
The answer given by @mirokropacek works for Linux (and presumably Mac, too) but doesn't work for Windows, unfortunately. This is due to the way the
register_usb_transport
function is called in Windows. It turns out the devpath parameter is alwaysNULL
in Windows. I needed to handle the same situation so I adapted the solution given above to randomly generate a device ID for each device if theserial
parameter is NULL or it is empty (zero length).I don't need to worry about differentiating devices over long periods of time and many devices so generating a pseudo-random number for the device ID with
rand
, then usingsprintf
to create a string representation of that ID seems to be sufficient for my needs but YMMV. It only generates a 4-digit hex number but it works well enough for me (for now at least).I faced the very same problem. It's because the adb tool uses the serial numbers for identification of devices connected to usb instead of their device paths (which are unique for sure).
If you feel up to getting your hands dirty, download the Android source tree, go to
system/core/adb/transport.c
, change it to something like that:type
make adb
from the top level path and voila. Devices use usb paths for identification. Now you can install & execute all of the devices from Eclipse with one click.Additionally you can use below commands when to handle multiple instance attached (device + emulator)
-d
stands for device and-e
stands for emulatorIf you don't want to change the device itself, and/or don't have root access, and the device has network access, you could switch to using TCPIP instead of USB:
adb tcpip 5555
adb connect yourhostname
I've run this through SSH tunnels where it would connect to localhost, so all devices show up as 'localhost' which is quite unuseful. Adding hosts to /etc/hosts (that all pointed to localhost) fixed that for me.
Now newer
adb
supports transport ID besides serial number:Firstly run
You would see like below:
Now you could specify a device with
Today I found an easy solution for this issue.
You'll get list of devices with their qualifiers
Then you can use qualifiers instead of serial numbers like this
or with
transport_id
and-t