Skip to content

Commit

Permalink
Fix AVD creation hang when profile is not specified.
Browse files Browse the repository at this point in the history
  • Loading branch information
ychescale9 committed Dec 28, 2020
1 parent 045b7d8 commit 28373d3
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
6 changes: 3 additions & 3 deletions lib/emulator-manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 5 additions & 3 deletions src/emulator-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,12 @@ export async function launchEmulator(
disableAnimations: boolean
): Promise<void> {
// 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.');
Expand Down

0 comments on commit 28373d3

Please sign in to comment.