Skip to content

Commit

Permalink
Force new cmdline-tools installation
Browse files Browse the repository at this point in the history
  • Loading branch information
ychescale9 committed Oct 11, 2024
1 parent 4e2ec73 commit e5f0ca8
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
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);
}
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

0 comments on commit e5f0ca8

Please sign in to comment.