Skip to content

Allow setting environment variables in flutterflutterCustomEmulators #3267

@hossamdash

Description

@hossamdash

Launching the android emulator under arch linux, wayland and the sway wm results in it hanging for a minute and then failing to start with an error message :
Failed to launch Pixel: Error: Emulator didn't connect within 60 seconds.
starting the emulator from the terminal by $ /opt/android-sdk/emulator/emulator @flutter_emulator and seeing the error message

handleCpuAcceleration: feature check for hvf
emulator: INFO: QtLogger.cpp:68: Warning: Could not find the Qt platform plugin "wayland" in "/opt/android-sdk/emulator/lib64/qt/plugins" ((null):0, (null))


Fatal: This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem.

Available platform plugins are: xcb.
 ((null):0, (null))
emulator: INFO: QtLogger.cpp:68: Fatal: This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem.

Available platform plugins are: xcb.
 ((null):0, (null))


zsh: abort (core dumped)  /opt/android-sdk/emulator/emulator @flutter_emulator

I have the following in my environment file to make QT applications launch under wayland QT_QPA_PLATFORM=wayland. in order to make the android emulator work i have to prefix the emulator command with a env variable override like so
env QT_QPA_PLATFORM=xcb /opt/android-sdk/emulator/emulator @flutter_emulator or simply just
QT_QPA_PLATFORM=xcb /opt/android-sdk/emulator/emulator @flutter_emulator
how can i make the dart extension launch the emulator with this override?
what i tried :
in my settings.json of vscode

"dart.flutterCustomEmulators": [
        {
            "id": "flutter_emulator",
            "name": "Pixel",
            "executable": "QT_QPA_PLATFORM=xcb /opt/android-sdk/emulator/emulator",
        }
    ]

and

        {
            "id": "flutter_emulator",
            "name": "Pixel",
            "executable": "/opt/android-sdk/emulator/emulator",
            "args":["QT_QPA_PLATFORM=xcb "]
        }
    ]

both didn't work.
and the second attempt i knew was not going to work as the env override needs to happen at the begining of the command. could a way be provided to pass env variables overrides to the custom emulator configuration ?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions