Fix Android emulator boot: launch once in fixture, not per-test#33901
Merged
Fix Android emulator boot: launch once in fixture, not per-test#33901
Conversation
The Android emulator was failing because LaunchAndWaitForAvd was being called in every test's constructor, causing issues with: 1. Multiple attempts to launch the same emulator 2. Possible race conditions between tests 3. Unnecessary overhead recreating the emulator for each test Fixed by moving the emulator launch to AndroidEmulatorFixture constructor (one-time setup), matching how IOSSimulatorFixture handles the simulator. The collection fixture now: 1. Accepts SDK licenses 2. Installs the AVD 3. Launches and waits for the emulator to boot Individual tests no longer need to launch the emulator - they just use the already-running emulator from the shared fixture.
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes Android integration test failures by correcting the emulator lifecycle management. The emulator was being launched in each test's constructor instead of once in the shared collection fixture, causing "Failed to launch Test AVD" errors due to multiple launch attempts and race conditions.
Changes:
- Moved emulator launch from
AndroidTemplateTestsconstructor toAndroidEmulatorFixtureconstructor (one-time setup) - Added
_emulatorLogPathfield to fixture to store the log path for the single emulator launch - Removed per-test emulator launch logic from test constructor
- Updated comments to reflect the new lifecycle management
kubaflo
approved these changes
Feb 5, 2026
rmarinho
approved these changes
Feb 5, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Note
Are you waiting for the changes in this PR to be merged?
It would be very helpful if you could test the resulting artifacts from this PR and let us know in a comment if this change resolves your issue. Thank you!
Description of Change
The Android integration tests (
RunOnAndroid) were failing with "Failed to launch Test AVD" because the emulator was being launched in every test's constructor instead of once in the shared fixture.Root Cause:
The
AndroidTemplateTestsconstructor was callingLaunchAndWaitForAvd()for each test, which caused:Fix:
Moved the emulator launch from the test constructor to
AndroidEmulatorFixtureconstructor (one-time setup), matching howIOSSimulatorFixturehandles the simulator.The collection fixture now:
Individual tests no longer attempt to launch the emulator - they use the already-running emulator from the shared fixture.
Issues Fixed
Fixes Android integration test failures on CI