question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Allow setting environment variables in flutterflutterCustomEmulators

See original GitHub issue

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 ?

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:2
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
gusbemacbecommented, 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:

    "dart.env": 
    {
        "_JAVA_AWT_WM_NONREPARENTING": 1,
        "QT_QPA_PLATFORM": "xcb"
    },
    "dart.flutterCustomEmulators": 
    [
        {
            "id": "Pixel_2_API_29",
            "name": "Pixel 2 API 29",
            "executable": "QT_QPA_PLATFORM=xcb _JAVA_AWT_WM_NONREPARENTING=1 /home/gusbemacbe/Android/SDK/emulator/emulator",
            "args": 
            [
                "-avd",
                "@Pixel_2_API_29"
            ]
        }
    ],

Or

    "dart.flutterCustomEmulators": 
    [
        {
            "id": "Pixel_2_API_29",
            "name": "Pixel 2 API 29",
            "env": "QT_QPA_PLATFORM=xcb _JAVA_AWT_WM_NONREPARENTING=1 /home/gusbemacbe/Android/SDK/emulator/emulator -avd @Pixel_2_API_29"
        }
    ],
0reactions
DanTupcommented, Jun 22, 2021

@gusbemacbe you need to put them in the env key, something like this:

"dart.flutterCustomEmulators": [
	{
		"id": "Pixel_2_API_29",
		"name": "Pixel 2 API 29",
		"executable": "/home/gusbemacbe/Android/SDK/emulator/emulator",
		"args": [
			"-avd",
			"@Pixel_2_API_29"
		],
		"env": {
			"QT_QPA_PLATFORM": "xcb",
			"_JAVA_AWT_WM_NONREPARENTING": "1"
		}
	}
],
Read more comments on GitHub >

github_iconTop Results From Across the Web

How To Set Environment Variables - Twilio
Set Environment Variables using PowerShell​​ The following cmdlets for configuring environment variables will work on Windows, macOS, and Linux. ...
Read more >
Environment variables - AWS Amplify Hosting
Set environment variables · Sign in to the AWS Management Console and open the Amplify console . · In the Amplify console, choose...
Read more >
How to Set Environment Variables in Linux - Serverlab -
Learn how to set and list environment variables in Linux, as well as how to persist environment variables for the local user and...
Read more >
How to Set Environment Variables in Linux - phoenixNAP
Set an environment variable in Linux by following this short tutorial. Learn how to view and manage a list of environment variables.
Read more >
Create and Modify Environment Variables on Windows
If the PATH, ORACLE_SID, and ORACLE_HOME environment variables do not exist, you must create them.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found