Warm tip: This article is reproduced from serverfault.com, please click

Unable to run android emulator in build agent connected to my local machine in TFS

发布于 2020-11-28 09:46:02

I am stuck with an issue which I dont seem to find any way to fix it.

I have created a batch file to launch the android emulator

emulator -avd myEmulator -gpu swiftshader
adb wait-for-device

when I open cmd and run the batch file manually in my machine, I am able to launch the emulator.

Now, I have a Batch Task added in TFS which points to the above batch file in the repository.

enter image description here

Whenever I run the task, I see the below information

enter image description here

The emulator seems to be running in the backgroud because when I try and start the same emaulator manually when the build is running, it gives me the error Emulator is already running. How do I fix this. i want the emulator to launch and be visible. I didnot add any script to run in the background because if I run the batch file manually it seems to be working. Please help

Questioner
Hussain Sam
Viewed
0
PatrickLu-MSFT 2020-12-01 16:35:51

Update:

As an interactive process with auto-logon enabled. In some cases, you might need to run the agent interactively for production use - such as to run UI tests. When the agent is configured to run in this mode, the screen saver is also disabled.

Try to run your build agent under Interactive mode. More details please refer our official doc here: Interactive vs. service


According to your description, TFS seems succeed creates and starts emulator in background, and waiting for full android loading on emulator.

To get a workaround, could you try to run the emulator directly on the build agent machine instead of your local machine.

You could setup your own agent and instance on a local machine that runs an emulator. Check if this do the trick.