pbreault / adb-idea

A plugin for Android Studio and Intellij IDEA that speeds up your day to day android development.
Apache License 2.0
2.1k stars 256 forks source link

Multiple devices with the same serial are not supported #100

Open christxph opened 5 years ago

christxph commented 5 years ago

If you have connected multiple devices with the same serial (which, unfortunately, frequently happens with cheap Chinese devices), then you can only access one of them in adb idea.

This can be fixed by accessing devices using the -t instead of the -s flag:

-t ID      use device with given transport id
-s SERIAL  use device with given serial (overrides $ANDROID_SERIAL)

The transport id is assigned by the host system and unique per USB port, whereas the device serial is set by the manufacturer and quite a few manufacturers seem to not care about making the serial uniqiue.

The transport ids can be found out using:

> adb devices -l
List of devices attached
0123456789ABCDEF       device usb:338886656X product:xyz model:xyz device:xyz transport_id:56
0123456789ABCDEF       device usb:338886656X product:xyz model:xyz device:xyz transport_id:57

As you see, the serial is the same, but the transport_id differs between those devices.

Check this Stackoverflow answer for more information: https://stackoverflow.com/a/29966699

pbreault commented 5 years ago

That's an interesting bug. Thanks for the root cause analysis. Out of curiosity, does Studio see them as separate devices?

christxph commented 5 years ago

Android Studio doesn't detect them, instead it shows either just one of the devices or just Unknown: screenshot 2019-01-30 at 10 19 29

while adb devices returns all connected devices.