Skip to content

Commit 2cfd145

Browse files
authored
Fixed emulator download URL (#343)
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
1 parent e1bdfef commit 2cfd145

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

src/sdk-installer.ts

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ export async function installAndroidSdk(apiLevel: string, target: string, arch:
1717
try {
1818
console.log(`::group::Install Android SDK`);
1919
const isOnMac = process.platform === 'darwin';
20+
const isArm = process.arch === 'arm64';
2021

2122
if (!isOnMac) {
2223
await exec.exec(`sh -c \\"sudo chown $USER:$USER ${process.env.ANDROID_HOME} -R`);
@@ -50,7 +51,19 @@ export async function installAndroidSdk(apiLevel: string, target: string, arch:
5051
if (emulatorBuild) {
5152
console.log(`Installing emulator build ${emulatorBuild}.`);
5253
// TODO find out the correct download URLs for all build ids
53-
const downloadUrlSuffix = Number(emulatorBuild.charAt(0)) > 6 ? `_x64-${emulatorBuild}` : `-${emulatorBuild}`;
54+
var downloadUrlSuffix: string;
55+
const majorBuildVersion = Number(emulatorBuild);
56+
if (majorBuildVersion >= 8000000) {
57+
if (isArm) {
58+
downloadUrlSuffix = `_aarch64-${emulatorBuild}`;
59+
} else {
60+
downloadUrlSuffix = `_x64-${emulatorBuild}`;
61+
}
62+
} else if (majorBuildVersion >= 7000000) {
63+
downloadUrlSuffix = `_x64-${emulatorBuild}`;
64+
} else {
65+
downloadUrlSuffix = `-${emulatorBuild}`;
66+
}
5467
await exec.exec(`curl -fo emulator.zip https://dl.google.com/android/repository/emulator-${isOnMac ? 'darwin' : 'linux'}${downloadUrlSuffix}.zip`);
5568
await exec.exec(`unzip -o -q emulator.zip -d ${process.env.ANDROID_HOME}`);
5669
await io.rmRF('emulator.zip');

0 commit comments

Comments
 (0)