Skip to content

Commit

Permalink
Fixed emulator download URL
Browse files Browse the repository at this point in the history
Previous code worked in a wrong way. 
1. Getting the first char of a build number is mistake because now numbers start with 1, but whole number higher than the number which starts from 7.
2. URL was incorrect for arm mac machines. It needed to add `aarch64` suffix
  • Loading branch information
olegdolgikh authored Jul 4, 2023
1 parent e1bdfef commit d73b551
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/sdk-installer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export async function installAndroidSdk(apiLevel: string, target: string, arch:
try {
console.log(`::group::Install Android SDK`);
const isOnMac = process.platform === 'darwin';
const isArm = process.arch === 'arm64';

if (!isOnMac) {
await exec.exec(`sh -c \\"sudo chown $USER:$USER ${process.env.ANDROID_HOME} -R`);
Expand Down Expand Up @@ -50,7 +51,19 @@ export async function installAndroidSdk(apiLevel: string, target: string, arch:
if (emulatorBuild) {
console.log(`Installing emulator build ${emulatorBuild}.`);
// TODO find out the correct download URLs for all build ids
const downloadUrlSuffix = Number(emulatorBuild.charAt(0)) > 6 ? `_x64-${emulatorBuild}` : `-${emulatorBuild}`;
var downloadUrlSuffix: string;
const majorBuildVersion = Number(emulatorBuild);
if (majorBuildVersion >= 8000000) {
if (isArm) {
downloadUrlSuffix = `_aarch64-${emulatorBuild}`;
} else {
downloadUrlSuffix = `_x64-${emulatorBuild}`;
}
} else if (majorBuildVersion >= 7000000) {
downloadUrlSuffix = `_x64-${emulatorBuild}`;
} else {
downloadUrlSuffix = `-${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_HOME}`);
await io.rmRF('emulator.zip');
Expand Down

0 comments on commit d73b551

Please sign in to comment.