Skip to content

Commit 28373d3

Browse files
committed
Fix AVD creation hang when profile is not specified.
1 parent 045b7d8 commit 28373d3

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

lib/emulator-manager.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,10 @@ const EMULATOR_BOOT_TIMEOUT_SECONDS = 600;
3737
function launchEmulator(apiLevel, target, arch, profile, sdcardPathOrSize, avdName, emulatorOptions, disableAnimations) {
3838
return __awaiter(this, void 0, void 0, function* () {
3939
// create a new AVD
40-
const profileOption = profile.trim() !== '' ? `--device "${profile}"` : '';
41-
const sdcardPathOrSizeOption = sdcardPathOrSize.trim() !== '' ? `--sdcard "${sdcardPathOrSize}"` : '';
40+
const profileOption = profile.trim() !== '' ? `--device '${profile}'` : '';
41+
const sdcardPathOrSizeOption = sdcardPathOrSize.trim() !== '' ? `--sdcard '${sdcardPathOrSize}'` : '';
4242
console.log(`Creating AVD.`);
43-
yield exec.exec(`avdmanager create avd --force -n "${avdName}" --abi "${target}/${arch}" --package "system-images;android-${apiLevel};${target};${arch}" ${profileOption} ${sdcardPathOrSizeOption}`);
43+
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}"`);
4444
// start emulator
4545
console.log('Starting emulator.');
4646
// turn off hardware acceleration on Linux

src/emulator-manager.ts

+5-3
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,12 @@ export async function launchEmulator(
1616
disableAnimations: boolean
1717
): Promise<void> {
1818
// create a new AVD
19-
const profileOption = profile.trim() !== '' ? `--device "${profile}"` : '';
20-
const sdcardPathOrSizeOption = sdcardPathOrSize.trim() !== '' ? `--sdcard "${sdcardPathOrSize}"` : '';
19+
const profileOption = profile.trim() !== '' ? `--device '${profile}'` : '';
20+
const sdcardPathOrSizeOption = sdcardPathOrSize.trim() !== '' ? `--sdcard '${sdcardPathOrSize}'` : '';
2121
console.log(`Creating AVD.`);
22-
await exec.exec(`avdmanager create avd --force -n "${avdName}" --abi "${target}/${arch}" --package "system-images;android-${apiLevel};${target};${arch}" ${profileOption} ${sdcardPathOrSizeOption}`);
22+
await exec.exec(
23+
`sh -c \\"echo no | avdmanager create avd --force -n "${avdName}" --abi '${target}/${arch}' --package 'system-images;android-${apiLevel};${target};${arch}' ${profileOption} ${sdcardPathOrSizeOption}"`
24+
);
2325

2426
// start emulator
2527
console.log('Starting emulator.');

0 commit comments

Comments
 (0)