-
-
Save m1ga/7c139716704fa81d11ca6f89c22e34d3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# enable "dev mode" in the windows settings | |
# Open a new powershell as admin | |
# run: set-executionpolicy remotesigned | |
# execute this script | |
Echo "#####################################################################" | |
Echo "# Installing Titanium CLI including nodejs, openjdk and android sdk #" | |
Echo "##################################################################### " | |
$androidPath = 'c:\android\' | |
$javaPath = 'c:\java\' | |
Echo "======================================" | |
Echo "Downloading files... (around 330 MB)" | |
$ProgressPreference = 'SilentlyContinue' | |
Invoke-WebRequest 'https://nodejs.org/download/release/latest-v20.x/node-v20.10.0-x64.msi' -OutFile 'node.msi' | |
Invoke-WebRequest 'https://download.java.net/java/GA/jdk18/43f95e8614114aeaa8e8a5fcf20a682d/36/GPL/openjdk-18_windows-x64_bin.zip' -OutFile 'openjdk.zip' | |
Invoke-WebRequest https://dl.google.com/android/repository/commandlinetools-win-7583922_latest.zip -OutFile 'androidcli.zip' | |
Echo "======================================" | |
Echo ("Extract Android SDK to " + $androidPath) | |
mkdir $androidPath | |
mkdir ($androidPath + "cmdline-tools") | |
Expand-Archive androidcli.zip -DestinationPath ($androidPath + "\cmdline-tools") | |
mv ($androidPath + "cmdline-tools\cmdline-tools") ($androidPath + "cmdline-tools\latest") | |
Echo "======================================" | |
Echo ("Extract OpenJDK to " + $javaPath) | |
Expand-Archive openjdk.zip -DestinationPath $javaPath | |
Echo "======================================" | |
Echo "Set environment variables" | |
[Environment]::SetEnvironmentVariable("JAVA_HOME", $javaPath + "jdk-18", "Machine"); | |
[Environment]::SetEnvironmentVariable("ANDROID_SDK", $androidPath, "Machine"); | |
[Environment]::SetEnvironmentVariable("Path", $env:Path + ";C:\Program Files\nodejs;" + $androidPath + "platform-tools;"+$javaPath+"\jdk-18\bin", "Machine") | |
$env:Path = [Environment]::GetEnvironmentVariable("Path","Machine") | |
Echo "======================================" | |
Echo "Install nodejs" | |
Start-Process node.msi | |
Write-Host -NoNewLine 'Press any key to continue after nodejs is installed...'; | |
$null = $Host.UI.RawUI.ReadKey('NoEcho,IncludeKeyDown'); | |
Echo "======================================" | |
Echo "Install npm packages" | |
npm install -g titanium alloy | |
Echo "======================================" | |
Echo "Install Android SDK" | |
& ($androidPath + 'cmdline-tools\latest\bin\sdkmanager') @('--sdk_root='+$androidPath,'--update'); | |
$cmd = $androidPath + 'cmdline-tools\latest\bin\sdkmanager'; | |
$param = ('--sdk_root='+$androidPath), '"extras;android;m2repository"','"platforms;android-33"','"build-tools;30.0.2"','"platform-tools"'; | |
& $cmd $param | |
& ($androidPath + 'cmdline-tools\latest\bin\sdkmanager') @('--sdk_root='+$androidPath,'--licenses'); | |
Echo "" | |
Echo "" | |
Echo "======================================" | |
Echo "Start a new user powershell and run:" | |
Echo " ti sdk install latest" | |
Echo (" ti config android.sdkPath " + $androidPath) | |
Echo "======================================" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment