From 28373d3d4f6fd84759cc5532c022a40ae27b0a8d Mon Sep 17 00:00:00 2001 From: Yang Date: Mon, 28 Dec 2020 12:10:21 +1100 Subject: [PATCH 1/2] Fix AVD creation hang when profile is not specified. --- lib/emulator-manager.js | 6 +++--- src/emulator-manager.ts | 8 +++++--- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/lib/emulator-manager.js b/lib/emulator-manager.js index d7b99d9b1..5ee9f5e6d 100644 --- a/lib/emulator-manager.js +++ b/lib/emulator-manager.js @@ -37,10 +37,10 @@ const EMULATOR_BOOT_TIMEOUT_SECONDS = 600; function launchEmulator(apiLevel, target, arch, profile, sdcardPathOrSize, avdName, emulatorOptions, disableAnimations) { return __awaiter(this, void 0, void 0, function* () { // create a new AVD - const profileOption = profile.trim() !== '' ? `--device "${profile}"` : ''; - const sdcardPathOrSizeOption = sdcardPathOrSize.trim() !== '' ? `--sdcard "${sdcardPathOrSize}"` : ''; + const profileOption = profile.trim() !== '' ? `--device '${profile}'` : ''; + const sdcardPathOrSizeOption = sdcardPathOrSize.trim() !== '' ? `--sdcard '${sdcardPathOrSize}'` : ''; console.log(`Creating AVD.`); - yield exec.exec(`avdmanager create avd --force -n "${avdName}" --abi "${target}/${arch}" --package "system-images;android-${apiLevel};${target};${arch}" ${profileOption} ${sdcardPathOrSizeOption}`); + yield exec.exec(`sh -c \\"echo no | avdmanager create avd --force -n "${avdName}" --abi '${target}/${arch}' --package 'system-images;android-${apiLevel};${target};${arch}' ${profileOption} ${sdcardPathOrSizeOption}"`); // start emulator console.log('Starting emulator.'); // turn off hardware acceleration on Linux diff --git a/src/emulator-manager.ts b/src/emulator-manager.ts index 35cfc6c57..3065a86f8 100644 --- a/src/emulator-manager.ts +++ b/src/emulator-manager.ts @@ -16,10 +16,12 @@ export async function launchEmulator( disableAnimations: boolean ): Promise { // create a new AVD - const profileOption = profile.trim() !== '' ? `--device "${profile}"` : ''; - const sdcardPathOrSizeOption = sdcardPathOrSize.trim() !== '' ? `--sdcard "${sdcardPathOrSize}"` : ''; + const profileOption = profile.trim() !== '' ? `--device '${profile}'` : ''; + const sdcardPathOrSizeOption = sdcardPathOrSize.trim() !== '' ? `--sdcard '${sdcardPathOrSize}'` : ''; console.log(`Creating AVD.`); - await exec.exec(`avdmanager create avd --force -n "${avdName}" --abi "${target}/${arch}" --package "system-images;android-${apiLevel};${target};${arch}" ${profileOption} ${sdcardPathOrSizeOption}`); + await exec.exec( + `sh -c \\"echo no | avdmanager create avd --force -n "${avdName}" --abi '${target}/${arch}' --package 'system-images;android-${apiLevel};${target};${arch}' ${profileOption} ${sdcardPathOrSizeOption}"` + ); // start emulator console.log('Starting emulator.'); From 0d8602fe476684693551d58672bc2a94f49044ed Mon Sep 17 00:00:00 2001 From: Yang Date: Mon, 28 Dec 2020 13:59:41 +1100 Subject: [PATCH 2/2] Prepare for release 2.14.1. --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index e51ab0c59..18af4da41 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Change Log +## v2.14.1 + +* Fix hang during AVD creation when `profile` is not specified - [#113](https://github.com/ReactiveCircus/android-emulator-runner/issues/113). + ## v2.14.0 * Support specifying SD card path or size via `sdcard-path-or-size`.