Skip to content

CLI: consider adopting AvdManagerRunner.ListDeviceProfilesAsync() for emulator device picker #306

@rmarinho

Description

@rmarinho

Context

Follow-up from #305 (Xamarin.Android.Tools.AndroidSdk bump to 1.0.179-ci.main.323).

Upstream dotnet/android-tools#325 added a new public API:

Task<IReadOnlyList<AvdDeviceProfile>> AvdManagerRunner.ListDeviceProfilesAsync(CancellationToken)
// where AvdDeviceProfile is `record AvdDeviceProfile(string Id)`

This wraps avdmanager list device --compact, so it returns the full set of device profiles the installed Android SDK knows about — not just a curated short list.

Current state

src/Cli/Microsoft.Maui.Cli/Commands/AndroidCommands.Emulator.cs (~L130) hard-codes a curated list for the interactive device picker:

var deviceProfiles = new List<(string Id, string Name)>
{
    ("pixel_6", "Pixel 6"),
    ("pixel_8", "Pixel 8"),
    ("pixel_9", "Pixel 9"),
    ("pixel_fold", "Pixel Fold"),
    ("pixel_tablet", "Pixel Tablet"),
    ("medium_phone", "Medium Phone"),
    ("small_phone", "Small Phone"),
};

We picked this list intentionally to keep the picker short and focused on common Pixel/generic profiles. The new upstream API returns 30+ raw IDs with no friendly names, so swapping it in directly would regress the prompt UX.

Proposal

A reasonable middle ground:

  • Keep the curated short list as the default picker (good UX out of the box).
  • Add an "All device profiles…" entry at the bottom of the prompt that, when selected, calls _runner.ListDeviceProfilesAsync() and shows the full list.
  • (Optional) Add a --list-all-devices / --device autocomplete affordance so maui android emulator create --device <tab> can complete against the full set.

This way users still get the fast curated path but aren't blocked when they want a specific non-Pixel profile (Nexus, Wear, TV, automotive, foldables, etc.).

Out of scope

  • Mapping all upstream IDs to friendly names — avdmanager doesn't return them and maintaining a map ourselves would drift.
  • Replacing the curated default list entirely.

Related

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions