Skip to content

Instantly share code, notes, and snippets.

@m1ga
Last active Jan 22, 2022
Embed
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 'https://nodejs.org/download/release/v14.18.3/node-v14.18.3-x64.msi' -OutFile 'node-v14.18.3-x64.msi'
Invoke-WebRequest 'https://download.java.net/java/GA/jdk11/9/GPL/openjdk-11.0.2_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-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