2022-03-02 10:24:47 +03:00
|
|
|
Param(
|
2024-07-29 15:48:02 +03:00
|
|
|
[Parameter(Mandatory)] [string[]] $API
|
2022-03-02 10:24:47 +03:00
|
|
|
)
|
|
|
|
|
|
|
|
$ErrorActionPreference = 'Stop'
|
|
|
|
|
|
|
|
.\scripts\install-android-sdk.ps1
|
2024-07-29 15:48:02 +03:00
|
|
|
|
2022-03-02 10:24:47 +03:00
|
|
|
$sdk = "$env:ANDROID_SDK_ROOT"
|
2024-07-29 15:48:02 +03:00
|
|
|
$sdkmanager = "$env:ANDROID_SDK_MANAGER_PATH"
|
2022-03-02 10:24:47 +03:00
|
|
|
|
2024-07-29 15:48:02 +03:00
|
|
|
$apis = $API -split ','
|
|
|
|
Write-Host "Installing $($apis.Count) Android API levels $API..."
|
2022-03-02 10:24:47 +03:00
|
|
|
|
2024-07-29 15:48:02 +03:00
|
|
|
# install each of the APIs
|
|
|
|
foreach ($API in $apis) {
|
|
|
|
Write-Host "Installing Android API level $API..."
|
2022-03-02 10:24:47 +03:00
|
|
|
|
2024-07-29 15:48:02 +03:00
|
|
|
# check if already installed
|
|
|
|
$apiPath = Join-Path "$sdk" "platforms" "android-$API" "android.jar"
|
|
|
|
if (Test-Path $apiPath) {
|
|
|
|
Write-Host "Android API level $API was already installed."
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
|
|
|
|
# install
|
|
|
|
Set-Content -Value "y" -Path "yes.txt"
|
|
|
|
try {
|
|
|
|
Write-Host "Installing Android API level $API..."
|
|
|
|
if ($IsMacOS -or $IsLinux) {
|
|
|
|
sh -c "'$sdkmanager' 'platforms;android-$API' < yes.txt"
|
|
|
|
} else {
|
|
|
|
cmd /c "`"$sdkmanager`" `"platforms;android-$API`" < yes.txt"
|
|
|
|
}
|
|
|
|
if (!$?) {
|
|
|
|
Write-Host "Failed to install Android API level $API."
|
|
|
|
exit 1
|
|
|
|
}
|
|
|
|
Write-Host "Installation of Android API level $API complete."
|
|
|
|
} finally {
|
|
|
|
Remove-Item "yes.txt"
|
2022-03-02 10:24:47 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
exit $LASTEXITCODE
|