Repository navigation
Allow setting environment variables in flutterflutterCustomEmulators #3267
Description
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 ?
Activity
DanTup commentedon Apr 12, 2021
Is there any harm in setting
QT_QPA_PLATFORM=xcbfor all Dart/Flutter process spawned by the extension?If not, then you could use the
dart.envsetting, either at the User Settings level or Workspace Settings:If that doesn't work, then we could extend
flutterCustomEmulatorsto have anenvkey too.DanTup commentedon Apr 12, 2021
(you may not even need
flutterCustomEmulatorsat all if settingdart.envwill work for you)hossamdash commentedon Apr 12, 2021
Thanks, that did the trick. I still think adding an
envkey toflutterCustomEmulatorswould be a good option - although not a very important one - to have if another QT application { a different emulator, a web browser maybe?, etc.. } were to support native wayland while the one from google didn't and you wanted to use them both. feel free to close this for now![-]Google's android emulator not launching under wayland[/-][+]Allow setting environment variables in flutterflutterCustomEmulators[/+]DanTup commentedon Apr 12, 2021
Yeah, I think so too - I've updated the title of this issue for that. Thanks!
gusbemacbe commentedon Jun 21, 2021
Hello @hossamdash and @DanTup !
I also run Manjaro with Sway, and have your problem, but I tried your settings and it did not work at all. I tried:
Or
gusbemacbe commentedon Jun 22, 2021
I was able to run
QT_QPA_PLATFORM=xcb _JAVA_AWT_WM_NONREPARENTING=1 flutter emulators --launch Pixel_2_API_29from command line in terminal, and pressed F5 to launch my project to the emulator.DanTup commentedon Jun 22, 2021
@gusbemacbe you need to put them in the
envkey, something like this: