Skip to content

Changes to fix Android emulators boot issues on Linux #28882

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Apr 16, 2025
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions eng/devices/android.cake
Original file line number Diff line number Diff line change
Expand Up @@ -593,6 +593,33 @@ void PrepareDevice(bool waitForBoot)
settings.Serial = DEVICE_UDID;
}

// Ensure adbkey and adbkey.pub are in place in CI builds
if (IsCIBuild())
{
Information("Ensuring ADB keys are correctly configured for CI environment...");
try
{
var adbKeyPath = System.IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), ".android");
var adbKeyFile = System.IO.Path.Combine(adbKeyPath, "adbkey");
var adbKeyPubFile = System.IO.Path.Combine(adbKeyPath, "adbkey.pub");

// Deletes existing adbkey and adbkey.pub files in the ~/.android directory to ensure no stale keys remain
if (System.IO.File.Exists(adbKeyFile)) System.IO.File.Delete(adbKeyFile);
if (System.IO.File.Exists(adbKeyPubFile)) System.IO.File.Delete(adbKeyPubFile);

// Regenerates ADB keys using AdbKillServer and AdbStartServer
Information("Regenerating ADB keys...");
AdbKillServer(settings);
AdbStartServer(settings);

Information("ADB keys have been successfully regenerated.");
}
catch (Exception ex)
{
Warning($"Error ensuring ADB keys: {ex.Message}");
}
}

if (waitForBoot)
{
Information("Waiting for the emulator to finish booting...");
Expand Down
Loading