Skip to content
5 changes: 4 additions & 1 deletion lib/sdk-installer.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ function installAndroidSdk(apiLevel, target, arch, channelId, emulatorBuild, ndk
const isOnMac = process.platform === 'darwin';
const isArm = process.arch === 'arm64';
const cmdlineToolsPath = `${process.env.ANDROID_HOME}/cmdline-tools`;
if (fs.existsSync(cmdlineToolsPath)) {
yield io.rmRF(cmdlineToolsPath);
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This may be a simpler / better approach than #411 - but with 411 there is the possibility we skip the install if the runner image ever has the updated version. That may have value

However I see this nice io.rmRF call and that's better than I do in 411 - I was shelling out to rm things

if (!fs.existsSync(cmdlineToolsPath)) {
console.log('Installing new cmdline-tools.');
const sdkUrl = isOnMac ? CMDLINE_TOOLS_URL_MAC : CMDLINE_TOOLS_URL_LINUX;
Expand All @@ -61,7 +64,7 @@ function installAndroidSdk(apiLevel, target, arch, channelId, emulatorBuild, ndk
yield io.mv(`${cmdlineToolsPath}/cmdline-tools`, `${cmdlineToolsPath}/latest`);
}
// add paths for commandline-tools and platform-tools
core.addPath(`${cmdlineToolsPath}/12.0:${cmdlineToolsPath}/12.0/bin:${process.env.ANDROID_HOME}/platform-tools`);
core.addPath(`${cmdlineToolsPath}/latest:${cmdlineToolsPath}/latest/bin:${process.env.ANDROID_HOME}/platform-tools`);
// set standard AVD path
core.exportVariable('ANDROID_AVD_HOME', `${process.env.HOME}/.android/avd`);
// accept all Android SDK licenses
Expand Down
7 changes: 4 additions & 3 deletions src/sdk-installer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ export async function installAndroidSdk(apiLevel: string, target: string, arch:
const isArm = process.arch === 'arm64';

const cmdlineToolsPath = `${process.env.ANDROID_HOME}/cmdline-tools`;

if (fs.existsSync(cmdlineToolsPath)) {
await io.rmRF(cmdlineToolsPath);
}
if (!fs.existsSync(cmdlineToolsPath)) {
console.log('Installing new cmdline-tools.');
const sdkUrl = isOnMac ? CMDLINE_TOOLS_URL_MAC : CMDLINE_TOOLS_URL_LINUX;
Expand All @@ -28,9 +32,6 @@ export async function installAndroidSdk(apiLevel: string, target: string, arch:
await io.mv(`${cmdlineToolsPath}/cmdline-tools`, `${cmdlineToolsPath}/latest`);
}

// print all folders under cmdline-tools
await exec.exec(`ls -l ${cmdlineToolsPath}`);

// add paths for commandline-tools and platform-tools
core.addPath(`${cmdlineToolsPath}/latest:${cmdlineToolsPath}/latest/bin:${process.env.ANDROID_HOME}/platform-tools`);

Expand Down