Skip to content

flutter devices doesn't properly list emulator names #11850

Open

Description

@mit-mit

Steps to Reproduce

  1. Create and name some AVDs in the Android Virtual Device Manager
  2. Run flutter devices

=> list shows the wrong names of the AVDs

screen shot 2017-08-30 at 16 00 09

mit-macbookpro2:battery mit$ flutter devices
2 connected devices:

Android SDK built for x86 64 • emulator-5554                        • android-x64 • Android 7.1.1 (API 25) (emulator)
iPhone 5s                    • 603DCE1D-B3A5-48CD-A309-1C45ED7AC3CF • ios         • iOS 10.3 (simulator)

Activity

  1. added
    toolAffects the "flutter" command-line tool. See also t: labels.
    platform-androidAndroid applications specifically
    on Aug 30, 2017
  2. mit-mit commented on Aug 30, 2017

    @mit-mit
    MemberAuthor

    cc @tvolkert any idea who knows how this device detection works?

  3. mit-mit commented on Aug 30, 2017

    @mit-mit
    MemberAuthor

    cc @devoncarew looks like the devices are correctly named in IntelliJ. How do we get the names there?

    screen shot 2017-08-30 at 16 02 47

  4. devoncarew commented on Aug 30, 2017

    @devoncarew
    Contributor

    Hmm, we're using the same logic as flutter_tools (and in fact, just asking it for the list of devices). AVDs names can be different from the device names that start from the AVD; I don't know of a way (using the android tools) to reconcile the names.

  5. tvolkert commented on Sep 7, 2017

    @tvolkert
    Contributor

    looks like the devices are correctly named in IntelliJ

    The IntelliJ screenshot shows the same output as flutter devices (which makes sense since it just delegates to flutter_tools).

    @mit-mit if you do a straight-up adb devices, which name does it list?

  6. mit-mit commented on Sep 11, 2017

    @mit-mit
    MemberAuthor

    Sorry, I should have been more clear: IntelliJ seems to show a different string for emulators that are already running, and ones that are not running. The names for the stopped ones are the correct/interesting ones:

    image

    screen shot 2017-09-11 at 14 19 37

  7. mit-mit commented on Sep 11, 2017

    @mit-mit
    MemberAuthor

    mit-mit if you do a straight-up adb devices, which name does it list?

    That gives me a third set of names:

    mit-macbookpro2:trans mit$ adb devices
    List of devices attached
    emulator-5556	device
    emulator-5554	device
    
  8. devoncarew commented on Sep 11, 2017

    @devoncarew
    Contributor

    IntelliJ seems to show a different string for emulators that are already running

    These names we're getting from adb (adb devices -l may show you longer versions of the names).

    and ones that are not running

    These names we're getting from the emulator command. I don't know how to reconcile the names from the two commands - to match up which one goes with which device.

  9. devoncarew commented on Sep 19, 2017

    @devoncarew
    Contributor

    These links may provide some hint for getting better device names:

    • android/tools/adt/idea/android/src/com/android/tools/idea/run/AndroidDeviceRenderer.java
    • android/tools/adt/idea/android/src/com/android/tools/idea/explorer/adbimpl/AdbDeviceFileSystemRenderer.java
  10. zoechi commented on Dec 28, 2018

    @zoechi
    Contributor

    The highlighted emulator is started

    image

    The selected shows just
    image

    This output doesn't contain the custom defined name Pixel 2 API 28

     $ adb devices -l
    List of devices attached
    emulator-5554          device product:sdk_gphone_x86 model:Android_SDK_built_for_x86 device:generic_x86 transport_id:5
    

    This produces different output but still does not contain my custom defined name.

     $ flutter devices
    1 connected device:
    
    Android SDK built for x86 • emulator-5554 • android-x86 • Android 9 (API 28) (emulator)
    
  11. DanTup commented on May 22, 2019

    @DanTup
    Contributor

    @jonahwilliams @devoncarew FYI - this might be relevant if we start showing devices + emulators in a single list in future. Running emulators would appear twice (once as a running device, once as an available emulator - which may fail to launch because it's already running).

    The answer may be in the Android Studio files Devon mentions above, though I couldn't find anything obvious with a quick dig around there.

  12. DanTup commented on Sep 11, 2019

    @DanTup
    Contributor

    @mit-mit @devoncarew I was just making some improvements in this area in VS Code after it came up again. I got this working (by having VS Code use the Emulator name for the Device - it alread matches these up as part of the new device picker work) - here's the offline emulators:

    Screenshot 2019-09-11 at 11 29 29 am

    And after launching two of them, they now show with the same emulator names:

    Screenshot 2019-09-11 at 11 28 46 am

    Previously they'd show as "Android SDK built for x86 (mobile)".

    However I'm thinking again about whether we should do it here instead so all editors and cli get it. Running flutter devices would have to connect to each device (we already do that for the daemon devices now but not for the command line) and and then read the name from the ini files. We should have all the code to do this, so I think the implications are:

    • performance (it'll make flutter devices a little slower)
    • more potential for failure (running flutter devices might stall on timeouts for bad device connections, or fail to find the emulator files if they're not in a standard location)
    • leaking knowledge about emulators into the devices commands

    If we'd rather not do that, I'll finish the fix in VS Code, but otherwise I can try it here.

  13. added
    customer: crowdAffects or could affect many people, though not necessarily a specific customer.
    on Nov 1, 2019
  14. TahaTesser commented on Mar 12, 2020

    @TahaTesser
    Contributor

    Hi @mit-mit
    Given the merges and closed issues mentioned above
    Does this issue still exist?
    Thank you

  15. added
    waiting for responseThe Flutter team cannot make further progress on this issue until the original reporter responds
    on Mar 12, 2020
  16. DanTup commented on Mar 12, 2020

    @DanTup
    Contributor

    I think this still exists. The VS Code extension matches these up client-side to improve the presentation there (emulators and devices are shown in the same list so without this, the same device would appear twice with different names). It would be nice to have that logic handler in Flutter though (for the benefit of other editors and the command line tool).

  17. removed
    waiting for responseThe Flutter team cannot make further progress on this issue until the original reporter responds
    on Apr 7, 2020
  18. added
    P3Issues that are less important to the Flutter project
    on Feb 2, 2022
  19. jacob314 commented on Oct 25, 2023

    @jacob314
    Contributor

    Fyi @christopherfujino now could be a good time to revisit this. We're now adding a delay to Flutter Tools to wait for iOS devices connected via WIFI on Mac so it would be faster if we loaded the proper emulator names at the same time as we waited for wifi devices to show up (relative to waiting for the emulator names from VSCode like we do now). This would also help keep the DevExp experience consistent across all IDEs.

  20. jacob314 commented on Oct 25, 2023

    @jacob314
    Contributor

    Fyi @DanTup who added the support for this directly to the VSCode plugin

  21. DanTup commented on Oct 26, 2023

    @DanTup
    Contributor

    I think there are probably a few parts to this. There are a few different places we output devices but it's not clear to me exactly what should show where:

    1. Output of flutter devices

    This is a simple table like:

    Found 4 connected devices:
      sdk gphone x86 64 (mobile) • emulator-5554 • android-x64    • Android 13 (API 33) (emulator)
      Windows (desktop)          • windows       • windows-x64    • Microsoft Windows [Version 10.0.22621.2283]
      Chrome (web)               • chrome        • web-javascript • Google Chrome 118.0.5993.89
      Edge (web)                 • edge          • web-javascript • Microsoft Edge 117.0.2045.43
    

    The top item here is an emulator and the emulator name (which we get by connecting to the emulator) is Pixel_3a_API_33_x86_64. Should this name replace one of the existing fields, or should we add a new column for the name from the emulator?

    2. Output of flutter devices --machine

    This output is JSON, and includes devices like:

      {
        "name": "sdk gphone x86 64",
        "id": "emulator-5554",
        "isSupported": true,
        "targetPlatform": "android-x64",
        "emulator": true,
        "sdk": "Android 13 (API 33)",
        "capabilities": {
          "hotReload": true,
          "hotRestart": true,
          "screenshot": true,
          "fastStart": true,
          "flutterExit": true,
          "hardwareRendering": true,
          "startPaused": true
        }
      },

    Should we add new fields (emulatorId, emulatorName?), or replace the existing name? Or a new field that is the whole emulator object? The work is essentially the same as the above, we just need to define the output format (replacing the existing name will show up in IDEs without changes, but adding new fields will require some IDE changes).

    3. flutter daemon device events

    This is what the IDEs use, and when a new device shows up it sends a payload like this:

    {
    	"event": "device.added",
    	"params": {
    		"id": "emulator-5554",
    		"name": "sdk gphone x86 64",
    		"platform": "android-x64",
    		"emulator": true,
    		"category": "mobile",
    		"platformType": "android",
    		"ephemeral": true,
    		"emulatorId": "Pixel_3a_API_33_x86_64",
    		"sdk": "Android 13 (API 33)",
    		"capabilities": {
    			"hotReload": true,
    			"hotRestart": true,
    			"screenshot": true,
    			"fastStart": true,
    			"flutterExit": true,
    			"hardwareRendering": true,
    			"startPaused": true
    		}
    	}
    }

    The JSON here is the same as the above so we'd probably want to match it. We'd probably want to keep a short cache of emulators to look up the names (since we only get the IDs when we connect to the emulator). Without a cache we'll fetch the emulators multiple times when several devices show up at startup, and with a long cache we don't detect newly-created emulators while the IDE is open.

  22. ahmdt commented on Dec 18, 2024

    @ahmdt

    It would be useful to get to get DanTup's suggestion implemented. Still cant map emulator names to device id for effective integration testing in ci.

    Edit:
    I found a solution per bash magic for android devices. Just replace my_custom_emulator_name and you will get the emulator_id as stated in flutter devices and you are able to use the -d parameter for flutter run.

    adb devices | sed 1d | xargs -L1 | awk '{print $1}' | while read -r line; do echo "$line $(adb -s $line emu avd name)\t"; done | awk '$2 ~ /my_custom_emulator_name/ {print $1; found=1} END {exit !found}'
    
  23. added a commit that references this issue on May 14, 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

    P3Issues that are less important to the Flutter projectcustomer: crowdAffects or could affect many people, though not necessarily a specific customer.platform-androidAndroid applications specificallyteam-androidOwned by Android platform teamtoolAffects the "flutter" command-line tool. See also t: labels.triaged-androidTriaged by Android platform team

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions