{"record":{"id":"fcd8bb012fb45ab8","repo":"dotnet/maui","slug":"the-emulator-did-not-finish-booting-in-time","errorCode":null,"errorMessage":"The emulator did not finish booting in time.","messagePattern":"The emulator did not finish booting in time\\.","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"eng/devices/android.cake","lineNumber":769,"sourceCode":"\t{\n\t\tsettings.Serial = DEVICE_UDID;\n\t}\n\n\tif (waitForBoot)\n\t{\n\t\tInformation(\"Waiting for the emulator to finish booting...\");\n\n        // Wait for the emulator to finish booting\n        var waited = 0;\n        var total = EmulatorBootTimeoutSeconds;\n        while (SafeAdbShell(\"getprop sys.boot_completed\", settings).FirstOrDefault() != \"1\")\n\t\t{\n\t\t    System.Threading.Thread.Sleep(1000);\n\n            Information(\"Waiting {0}/{1} seconds for the emulator to boot up.\", waited, total);\n            if (waited++ > total)\n            {\n                throw new Exception(\"The emulator did not finish booting in time.\");\n            }\n\n            // At 90 seconds, restart ADB server to recover from authorization issues\n            if (waited == 90 && IsCIBuild())\n            {\n                Information(\"Emulator boot taking longer than expected (90/{0} seconds). Restarting ADB server...\", total);\n                try\n                {\n                    Information(\"Stopping ADB server...\");\n                    AdbKillServer(settings);\n                    System.Threading.Thread.Sleep(2000);\n                    \n                    Information(\"Starting ADB server...\");\n                    AdbStartServer(settings);\n                    System.Threading.Thread.Sleep(2000);\n                    \n                    Information(\"ADB server restart completed. Continuing to wait for emulator boot...\");\n                }","sourceCodeStart":751,"sourceCodeEnd":787,"githubUrl":"https://github.com/dotnet/maui/blob/f377ff1c5ee04d334d8a925f50c83a6b7afddf03/eng/devices/android.cake#L751-L787","documentation":"Thrown when the emulator boot-watchdog loop exceeds EmulatorBootTimeoutSeconds (10 minutes) without sys.boot_completed reporting '1'. Each second the loop checks SafeAdbShell('getprop sys.boot_completed'); if the counter passes the budget it aborts. At 90s in CI it also tries restarting the ADB server to recover from auth issues.","triggerScenarios":"The emulator fails to reach sys.boot_completed=1 within 600 seconds. Causes include slow/emulator-starved hosts, AVD stuck on boot animation, disk image corruption, HAXM/Hyper-V/KVM acceleration unavailable, or ADB authorization blocking the device.","commonSituations":"Underpowered CI agents without hardware acceleration; a corrupted AVD snapshot; cold boot of a large API-level image; ADB key authorization pending; emulator process hung.","solutions":["Ensure hardware acceleration is enabled (Hypervisor Framework on macOS, KVM on Linux, Hyper-V/WHPX on Windows) — without it boot can exceed 10 min.","Wipe the AVD data/cold-boot: delete the snapshot or recreate the AVD to clear corruption.","Increase EmulatorBootTimeoutSeconds for slow agents, or allocate more RAM/CPU to the emulator.","Watch the 90-second ADB-restart log line; if it appears, the issue is likely ADB authorization — ensure ADB keys are set up (see ADB key errors).","Check emulator logs (e.g. ~/.android/avd/<name>.avd/logs) for the underlying hang."],"exampleFix":null,"handlingStrategy":"retry","validationCode":"// Pre-flight: confirm emulator is reachable before boot-watchdog\nif (!SafeAdbShell(\"getprop sys.boot_completed\", settings).Any()) {\n    Warning(\"Emulator not responding to adb; boot watchdog may time out.\");\n}","typeGuard":null,"tryCatchPattern":"for (int bootAttempt = 1; bootAttempt <= 2; bootAttempt++) {\n    try {\n        WaitForEmulatorBoot(settings, EmulatorBootTimeoutSeconds);\n        break;\n    } catch when (bootAttempt < 2) {\n        Warning(\"Boot timed out; wiping AVD data and retrying.\");\n        WipeAndRestartEmulator(settings);\n    }\n}","preventionTips":["Enable hardware acceleration on all agents that run the emulator.","Use warm/snapshotted AVDs to cut boot time under the budget.","Surface emulator logs in CI when the watchdog throws for post-mortem."],"tags":["android","emulator","boot-timeout","adb","ci"],"backgroundTag":null,"analyzedSha":"f377ff1c5ee04d334d8a925f50c83a6b7afddf03","analyzedAt":"2026-08-13T14:26:18.069Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}