Skip to content

Fix Android emulator boot: launch once in fixture, not per-test#33901

Merged
rmarinho merged 1 commit intomainfrom
fix/android-emulator-boot-failure
Feb 5, 2026
Merged

Fix Android emulator boot: launch once in fixture, not per-test#33901
rmarinho merged 1 commit intomainfrom
fix/android-emulator-boot-failure

Conversation

@PureWeen
Copy link
Member

@PureWeen PureWeen commented Feb 5, 2026

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 AndroidTemplateTests constructor was calling LaunchAndWaitForAvd() for each test, which caused:

  1. Multiple attempts to launch the same emulator
  2. Possible race conditions between tests
  3. Each test waiting 600 seconds for an emulator that may have already failed to boot in a previous test

Fix:
Moved the emulator launch from the test constructor 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 (NEW)

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

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.
Copilot AI review requested due to automatic review settings February 5, 2026 02:45
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 AndroidTemplateTests constructor to AndroidEmulatorFixture constructor (one-time setup)
  • Added _emulatorLogPath field 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

@rmarinho rmarinho merged commit fc05c0b into main Feb 5, 2026
30 of 34 checks passed
@rmarinho rmarinho deleted the fix/android-emulator-boot-failure branch February 5, 2026 11:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants