Skip to content

GetEmulatorAvdNameAsync should fallback to getprop when adb emu avd name returns empty #12078

Open

Description

@rmarinho

Problem

AdbRunner.GetEmulatorAvdNameAsync() uses adb -s <serial> emu avd name to resolve the AVD name of a running emulator. On ADB v36.0.0, this command returns empty output (exit code 0) — causing MergeDevicesAndEmulators() to fail deduplication, resulting in duplicate device entries (one running without AVD name + one "Not Running" from emulator -list-avds).

Root Cause

adb emu avd name returns empty on adb v36.0.0:

$ adb -s emulator-5554 emu avd name
(empty output, exit code 0)

But the correct name is available via shell property:

$ adb -s emulator-5554 shell getprop ro.boot.qemu.avd_name
MAUI_Emulator_API_36

Proposed Fix

In GetEmulatorAvdNameAsync(), add a fallback:

  1. Try adb emu avd name (existing behavior)
  2. If result is null/empty, try adb shell getprop ro.boot.qemu.avd_name
  3. Return the first non-empty result

Impact

This is a pre-existing bug on main — confirmed by testing dotnet run on dotnet/android main branch with an emulator running: same duplicate listing occurs. Not caused by the EmulatorRunner feature branch.

The same fix is also needed in dotnet/android's GetAvailableAndroidDevices.GetEmulatorAvdName() which has identical logic.

Activity

  1. added
    bug
    on Mar 17, 2026
  2. jonathanpeppers commented on Mar 17, 2026

    @jonathanpeppers
    Member

    I'm confused by the premise, this works for me:

    > adb -s emulator-5554 emu avd name
    pixel_7_-_api_36
    OK
    

    It was this emulator:

    Image
  3. added
    android-tools
    on Jul 13, 2026
  4. added
    needs-triage
    on Jul 13, 2026
  5. removed
    needs-triage
    on Nov 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    android-toolsbug

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions