How to get Android AVD name from adb device name
Asked Answered
A

3

31

Using the Android SDK from the command line, I can get a list of the running devices available using:

./adb device

This gives me the serial number of available devices. How can I get the AVD name of the emulator device from that serial number (like the Eclipse ADT plugin does)?

Astereognosis answered 5/12, 2011 at 7:6 Comment(0)
B
24

The Eclipse plugin does it by connecting to the emulator via tcp/ip. To connect, (for linux), type

~/code$ telnet localhost 5554
Trying ::1...
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
Android Console: type 'help' for a list of commands
OK

Replace "5554" with whatever number comes after the hyphen when you type "adb devices" - "emulator-5554", for instance, would have telnet port 5554 open.

Then, type "avd name", hit enter, and you should see something similar to the following:

avd name
GB10
OK

In this example the emulator's name was "GB10".

Bowden answered 6/12, 2011 at 0:6 Comment(4)
Never would have figured that out on my own. Thanks!Astereognosis
Is there any way to just invoke avd name from the command line without telnet?Thorpe
Nope. The avd command only exists on the emulated device, which is why you have to telnet into it to to run "avd name"Bowden
@Kvass: Here's a hack that simplifies the process (works on OS X): (sleep 0.5; echo 'avd name') | telnet 127.0.0.1 5554Transatlantic
K
39

Here it is:

> adb -s emulator-5554 emu avd name
MyDevice
OK
Kus answered 14/3, 2019 at 13:56 Comment(0)
B
24

The Eclipse plugin does it by connecting to the emulator via tcp/ip. To connect, (for linux), type

~/code$ telnet localhost 5554
Trying ::1...
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
Android Console: type 'help' for a list of commands
OK

Replace "5554" with whatever number comes after the hyphen when you type "adb devices" - "emulator-5554", for instance, would have telnet port 5554 open.

Then, type "avd name", hit enter, and you should see something similar to the following:

avd name
GB10
OK

In this example the emulator's name was "GB10".

Bowden answered 6/12, 2011 at 0:6 Comment(4)
Never would have figured that out on my own. Thanks!Astereognosis
Is there any way to just invoke avd name from the command line without telnet?Thorpe
Nope. The avd command only exists on the emulated device, which is why you have to telnet into it to to run "avd name"Bowden
@Kvass: Here's a hack that simplifies the process (works on OS X): (sleep 0.5; echo 'avd name') | telnet 127.0.0.1 5554Transatlantic
T
0

Using adb devices you can see the List of devices attached.

In my case the result is:

List of devices attached
emulator-5554   device
Thready answered 19/11, 2022 at 4:20 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.