Forked from FeodorFitsner/install-android-sdk.ps1
Last active
November 16, 2015 21:19
-
-
Save kerko/c50d7d1cbadc8d17d901 to your computer and use it in GitHub Desktop.
Installing Android SDKs
This file contains hidden or 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
| #$AndroidToolPath = "${env:ProgramFiles(x86)}\Android\android-sdk\tools\android" | |
| $AndroidToolPath = "$env:localappdata\Android\android-sdk\tools\android" | |
| Function Get-AndroidSDKs() { | |
| $output = & $AndroidToolPath list sdk --all | |
| $sdks = $output |% { | |
| if ($_ -match '(?<index>\d+)- (?<sdk>.+), revision (?<revision>[\d\.]+)') { | |
| $sdk = New-Object PSObject | |
| Add-Member -InputObject $sdk -MemberType NoteProperty -Name Index -Value $Matches.index | |
| Add-Member -InputObject $sdk -MemberType NoteProperty -Name Name -Value $Matches.sdk | |
| Add-Member -InputObject $sdk -MemberType NoteProperty -Name Revision -Value $Matches.revision | |
| $sdk | |
| } | |
| } | |
| $sdks | |
| } | |
| Function Install-AndroidSDK() { | |
| [CmdletBinding()] | |
| Param( | |
| [Parameter(Mandatory=$true, Position=0)] | |
| [PSObject[]]$sdks | |
| ) | |
| $sdkIndexes = $sdks |% { $_.Index } | |
| $sdkIndexArgument = [string]::Join(',', $sdkIndexes) | |
| Echo 'y' | & $AndroidToolPath update sdk -u -a -t $sdkIndexArgument | |
| } | |
| $sdks = Get-AndroidSDKs |? { $_.name -like 'sdk platform*API 23*' -or $_.name -like 'google apis*api 23' } | |
| Install-AndroidSDK -sdks $sdks |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment