install-windows-android.ps1 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. <#
  2. Copyright (c) Contributors to the Open 3D Engine Project.
  3. For complete copyright and license terms please see the LICENSE at the root of this distribution.
  4. SPDX-License-Identifier: Apache-2.0 OR MIT
  5. #>
  6. Import-Module C:\ProgramData\chocolatey\helpers\chocolateyInstaller.psm1
  7. #Android SDK Command line tools needs a custom installer due the latest command like version not being available in the Chocolatey repository
  8. $androidSdkPackageName = 'androidsdk'
  9. $androidSdkVersion = '11076708_latest'
  10. $androidSdkUrl = "https://dl.google.com/android/repository/commandlinetools-win-$androidSdkVersion.zip"
  11. $androidSdkChecksum = '4d6931209eebb1bfb7c7e8b240a6a3cb3ab24479ea294f3539429574b1eec862'
  12. $androidSdkInstallDir = "C:\AndroidSdk\cmdline-tools"
  13. $androidSdkLatestDir = "$androidSdkInstallDir\latest"
  14. Install-ChocolateyZipPackage $androidSdkPackageName $androidSdkUrl $androidSdkInstallDir -Checksum $androidSdkChecksum -ChecksumType 'sha256'
  15. [Environment]::SetEnvironmentVariable("ANDROID_SDK_ROOT", "C:\AndroidSdk", [EnvironmentVariableTarget]::Machine)
  16. # Rename the Android SDK folder 'cmdline-tools' to match what the command line tools looks like normally in a full AndroidSDK install
  17. Rename-Item -Path "$androidSdkInstallDir\cmdline-tools" "$androidSdkLatestDir"
  18. # Set package versions
  19. $android_packages = '"platforms;android-28" "platforms;android-29" "platforms;android-30"'
  20. $googleplay_packages = '"extras;google;market_apk_expansion" "extras;google;market_licensing"'
  21. $build_tools = '"build-tools;30.0.2" "build-tools;34.0.0" "tools"'
  22. $ndk = '"ndk;21.4.7075529" "ndk;23.1.7779620" "ndk;25.1.8937393" "ndk;25.2.9519653"'
  23. Write-Host "Installing Android SDK packages"
  24. $sdkmanager = "$androidSdkLatestDir\bin\sdkmanager.bat"
  25. Start-Process -FilePath $sdkmanager -ArgumentList "--licenses" -NoNewWindow -Wait # Accept all licenses manually
  26. Start-Process -FilePath $sdkmanager -ArgumentList $android_packages -NoNewWindow -Wait
  27. Start-Process -FilePath $sdkmanager -ArgumentList $googleplay_packages -NoNewWindow -Wait
  28. Start-Process -FilePath $sdkmanager -ArgumentList $build_tools -NoNewWindow -Wait
  29. Start-Process -FilePath $sdkmanager -ArgumentList $ndk -NoNewWindow -Wait
  30. # Set the NDK environment
  31. [Environment]::SetEnvironmentVariable("LY_NDK_DIR", "C:\AndroidSdk\ndk\25.1.8937393", [EnvironmentVariableTarget]::Machine)
  32. Write-Host "Installing Gradle"
  33. $gradle_version = '8.7'
  34. $gradle_checksum = '194717442575a6f96e1c1befa2c30e9a4fc90f701d7aee33eb879b79e7ff05c0'
  35. #Gradle needs a custom installer due to being hardcoded to C:\Programdata in Chocolatey
  36. Import-Module C:\ProgramData\chocolatey\helpers\chocolateyInstaller.psm1
  37. $packageName = 'gradle'
  38. $url = "https://services.gradle.org/distributions/gradle-$gradle_version-all.zip"
  39. $installDir = "C:\Gradle"
  40. Install-ChocolateyZipPackage $packageName $url $installDir -Checksum $gradle_checksum -ChecksumType 'sha256'
  41. $gradle_home = Join-Path $installDir "$packageName-$gradle_version"
  42. [Environment]::SetEnvironmentVariable("GRADLE_BUILD_HOME", $gradle_home, [EnvironmentVariableTarget]::Machine)
  43. [Environment]::SetEnvironmentVariable(
  44. "PATH",
  45. [Environment]::GetEnvironmentVariable("PATH", [EnvironmentVariableTarget]::Machine) + ";$gradle_home\bin",
  46. [EnvironmentVariableTarget]::Machine)
  47. Write-Host "Installing Ninja"
  48. $ninja_version = 1.10.0
  49. choco install -y ninja --version=$ninja_version --package-parameters="/installDir:C:\Ninja"
  50. [Environment]::SetEnvironmentVariable(
  51. "PATH",
  52. [Environment]::GetEnvironmentVariable("PATH", [EnvironmentVariableTarget]::Machine) + ";C:\Ninja",
  53. [EnvironmentVariableTarget]::Machine)