How to identify an android emulator (AVD) using ADB
Asked Answered
P

2

6

I use the emulator AVD and i have 3 android :

  • First name Android : test
  • Second name Android : test1
  • Third name Android : test2

I launch the first and second android with command line :

emulator -avd test
emulator -avd test1

And after, when i use this command line :

avd devices

I have

List of devices attached
emulator-5556 device
emulator-5554 device

How i can identify my android emulator with adb (only command line)?
If it's impossible, how I can know if my device is started with "emulator" (only command line) ?

Pheidippides answered 1/9, 2016 at 11:49 Comment(0)
M
5

Try doing a TELNET to the AVD

emulator -avd test
emulator -avd test1

avd devices

List of devices attached 
emulator-5556 device 
emulator-5554 device

telnet localhost 5554
Trying 127.0.0.1...
Connected to localhost.
...
OK
avd name
test1
Mordecai answered 1/9, 2016 at 11:56 Comment(2)
Kindly up-vote and accept my answer if it was helpful to you.Mordecai
Any other simple way?Emulsion
J
0

My verbose solution using a bash function:

get_adb_name() {
    # Check if the argument is provided
    if [ -z "$1" ]; then
        echo "Usage: get_adb_name <device_identifier>"
        return 1
    fi

    # Use the provided device identifier to construct the adb command
    adb -s "$1" emu avd name
}

Usage:

$ get_adb_name emulator-5554
Phone_API34_2
OK
Juneberry answered 30/4, 2024 at 13:31 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.