Skip to content

Instantly share code, notes, and snippets.

Last active Jan 22, 2022
What would you like to do?
# enable "dev mode" in the windows settings
# Open a new powershell as admin
# run: set-executionpolicy remotesigned
# execute this script
Echo "Install Titanium CLI including nodejs, openjdk and android sdk"
$androidPath = 'c:\android\'
$javaPath = 'c:\java\'
Echo "======================================"
Echo "Download files"
$ProgressPreference = 'SilentlyContinue'
Invoke-WebRequest '' -OutFile 'node-v14.18.3-x64.msi'
Invoke-WebRequest '' -OutFile ''
Invoke-WebRequest -OutFile ''
Echo "======================================"
Echo ("Extract Android SDK to " + $androidPath)
mkdir $androidPath
mkdir ($androidPath + "cmdline-tools")
Expand-Archive -DestinationPath ($androidPath + "\cmdline-tools")
mv ($androidPath + "cmdline-tools\cmdline-tools") ($androidPath + "cmdline-tools\latest")
Echo "======================================"
Echo ("Extract OpenJDK to " + $javaPath)
Expand-Archive -DestinationPath $javaPath
Echo "======================================"
Echo "Set environment variables"
[Environment]::SetEnvironmentVariable("JAVA_HOME", $javaPath + "jdk-11.0.2", "Machine");
[Environment]::SetEnvironmentVariable("ANDROID_SDK", $androidPath, "Machine");
[Environment]::SetEnvironmentVariable("Path", $env:Path + ";C:\Program Files\nodejs;" + $androidPath + "platform-tools;"+$javaPath+"\jdk-11.0.2\bin", "Machine")
$env:Path = [Environment]::GetEnvironmentVariable("Path","Machine")
Echo "======================================"
Echo "Install nodejs"
Start-Process node-v14.18.3-x64.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 appcelerator
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-31"','"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 10.1.1.GA"
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