Skip to content

Commit

Permalink
Unzip specific emulator build into latest emulator build from sdkmana…
Browse files Browse the repository at this point in the history
…ger. Support using modern build id for emulator-build.
  • Loading branch information
ychescale9 committed Jun 25, 2021
1 parent fe99eb1 commit 50ef017
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 13 deletions.
13 changes: 6 additions & 7 deletions lib/sdk-installer.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,17 +71,16 @@ function installAndroidSdk(apiLevel, target, arch, emulatorBuild, ndkVersion, cm
}
console.log('Installing latest build tools, platform tools, and platform.');
yield exec.exec(`sh -c \\"sdkmanager --install 'build-tools;${BUILD_TOOLS_VERSION}' platform-tools 'platforms;android-${apiLevel}' > /dev/null"`);
console.log('Installing latest emulator.');
yield exec.exec(`sh -c \\"sdkmanager --install emulator > /dev/null"`);
if (emulatorBuild) {
console.log(`Installing emulator build ${emulatorBuild}.`);
yield exec.exec(`curl -fo emulator.zip https://dl.google.com/android/repository/emulator-${isOnMac ? 'darwin' : 'linux'}-${emulatorBuild}.zip`);
yield io.rmRF(`${process.env.ANDROID_SDK_ROOT}/emulator`);
yield exec.exec(`unzip -q emulator.zip -d ${process.env.ANDROID_SDK_ROOT}`);
// TODO find out the correct download URLs for all build ids
const downloadUrlSuffix = Number(emulatorBuild.charAt(0)) > 6 ? `_x64-${emulatorBuild}` : `-${emulatorBuild}`;
yield exec.exec(`curl -fo emulator.zip https://dl.google.com/android/repository/emulator-${isOnMac ? 'darwin' : 'linux'}${downloadUrlSuffix}.zip`);
yield exec.exec(`unzip -o -q emulator.zip -d ${process.env.ANDROID_SDK_ROOT}`);
yield io.rmRF('emulator.zip');
}
else {
console.log('Installing latest emulator.');
yield exec.exec(`sh -c \\"sdkmanager --install emulator > /dev/null"`);
}
console.log('Installing system images.');
yield exec.exec(`sh -c \\"sdkmanager --install 'system-images;android-${apiLevel};${target};${arch}' > /dev/null"`);
if (ndkVersion) {
Expand Down
14 changes: 8 additions & 6 deletions src/sdk-installer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,15 +49,17 @@ export async function installAndroidSdk(apiLevel: number, target: string, arch:
console.log('Installing latest build tools, platform tools, and platform.');

await exec.exec(`sh -c \\"sdkmanager --install 'build-tools;${BUILD_TOOLS_VERSION}' platform-tools 'platforms;android-${apiLevel}' > /dev/null"`);

console.log('Installing latest emulator.');
await exec.exec(`sh -c \\"sdkmanager --install emulator > /dev/null"`);

if (emulatorBuild) {
console.log(`Installing emulator build ${emulatorBuild}.`);
await exec.exec(`curl -fo emulator.zip https://dl.google.com/android/repository/emulator-${isOnMac ? 'darwin' : 'linux'}-${emulatorBuild}.zip`);
await io.rmRF(`${process.env.ANDROID_SDK_ROOT}/emulator`);
await exec.exec(`unzip -q emulator.zip -d ${process.env.ANDROID_SDK_ROOT}`);
// TODO find out the correct download URLs for all build ids
const downloadUrlSuffix = Number(emulatorBuild.charAt(0)) > 6 ? `_x64-${emulatorBuild}` : `-${emulatorBuild}`;
await exec.exec(`curl -fo emulator.zip https://dl.google.com/android/repository/emulator-${isOnMac ? 'darwin' : 'linux'}${downloadUrlSuffix}.zip`);
await exec.exec(`unzip -o -q emulator.zip -d ${process.env.ANDROID_SDK_ROOT}`);
await io.rmRF('emulator.zip');
} else {
console.log('Installing latest emulator.');
await exec.exec(`sh -c \\"sdkmanager --install emulator > /dev/null"`);
}
console.log('Installing system images.');
await exec.exec(`sh -c \\"sdkmanager --install 'system-images;android-${apiLevel};${target};${arch}' > /dev/null"`);
Expand Down

0 comments on commit 50ef017

Please sign in to comment.