param ( [Parameter(Mandatory=$true)][String]$Package, [Parameter(Mandatory=$true)][String]$FileName, [Parameter(Mandatory=$true)][String]$Version, [Parameter(Mandatory=$true)][String]$Operation, [String]$OpenJDKVersion, [String[]]$RequestedAVDs, [String]$AndroidHome ) <# Download and install Android SDK #> Function Invoke-InteractiveProcess([String]$FilePath, [string[]]$ArgumentList) { $startInfo = New-Object System.Diagnostics.ProcessStartInfo $startInfo.FileName = $FilePath $startInfo.Arguments = $ArgumentList $startInfo.UseShellExecute = $false $startInfo.RedirectStandardInput = $true $startInfo.RedirectStandardOutput = $true $startInfo.CreateNoWindow = $true $process = [System.Diagnostics.Process]::Start($startInfo) return $process } # Android helper functions Function Get-AndroidHomeFromRegistry { Write-Host "Android home not specified - getting from registry." $ProgramFilesx86 = [environment]::GetEnvironmentVariable("ProgramFiles(x86)") # if ([Environment]::Is64BitOperatingSystem) # powershell v1 doesn't have is 64 bit flag. if ($ProgramFilesx86) { $androidRegistryKey = "HKLM:\SOFTWARE\Wow6432Node\Android SDK Tools" #Set the default value to use in case the reg key isn't set $path = "$ProgramFilesx86\Android\android-sdk" } else { $androidRegistryKey = "HKLM:\SOFTWARE\Android SDK Tools" #Set the default value to use in case the reg key isn't set $ProgramFiles = [environment]::GetEnvironmentVariable("ProgramFiles") $path = "$ProgramFiles\Android\android-sdk" } if (Test-Path $androidRegistryKey) { $path = (Get-ItemProperty $androidRegistryKey Path).Path } return $path } Function Format-List([string[]]$List) { if ($List.Count -gt 0) { return $List -join ", " } return "(none)" } Function Uninstall-Package ([string]$PackageName, [string]$Version) { Write-Host "`nUninstall requested for package '$PackageName' version $Version" $startTime = Get-Date $installPath = Get-InstallRoot -PackageName $PackageName $currentVersion = Get-CurrentPackageVersion -PackageName $PackageName -InstallPath $installPath $requiredVersion = New-Object System.Version (Get-ThreeDigitVerion -TestVersion $Version) if ($currentVersion -ne $requiredVersion) { Write-Host "- Skipping uninstall, since not installed or installed version does not match" } else { Uninstall-Folder -Path (Join-Path $AndroidHome $installPath) Write-Host "- Done. Elapsed time: $((Get-Date).Subtract($startTime).TotalSeconds) second(s)" } } Function Install-Package ([string]$PackageName, [string]$Operation) { Write-Host "`nInstalling package $PackageName" Write-Host "- Requested version: $Version" $installPath = Get-InstallRoot -PackageName $PackageName if ($Operation -ne "Repair") { $currentVersion = Get-CurrentPackageVersion -PackageName $PackageName -InstallPath $installPath $requiredVersion = New-Object System.Version (Get-ThreeDigitVerion -TestVersion $Version) if ($currentVersion -ge $requiredVersion) { Write-Host "- Nothing to do, since version $currentVersion is already installed" return $true } } $result = $true try { # Kill ADB process to avoid access denied errors Kill-ADB $targetInstallFolder = Join-Path $AndroidHome $installPath if (Test-Path $targetInstallFolder) { # Try to create a temporary folder to back up the existing package folder. We back it up to # another folder in the same parent folder to ensure we have access rights to this folder. # We do this first so we don't waste our time continuing if we don't have access rights. $currentPackageTempPath = Create-TempFolder -Parent $AndroidHome -Reason "backup of existing package" $currentPackageTempPathPackageFolder = Join-Path $currentPackageTempPath $installPath New-Item -ItemType Directory -Path $currentPackageTempPath -ErrorAction SilentlyContinue } $packageTargetFile = Join-Path $PSScriptRoot $FileName # Backup existing package if it exists if (Test-Path $targetInstallFolder) { Move-FolderWithRetry -Path $targetInstallFolder -Destination $currentPackageTempPath -Reason "Moving existing package to temporary folder" $existingPackageBackedUp = $true } # Unzip package to temp folder in android-sdk folder (this is important to get correct permissions) $newPackageTempPath = Create-TempFolder -Parent $AndroidHome -Reason "new package" Unzip-File -Source $packageTargetFile -Destination $newPackageTempPath # Move the correct contents of the zip file to the destination. If the zip file contained a single root # folder, then we copy the contents of that folder. Otherwise we just copy the contents of the zip file. # This is based on the Android SDK Manager logic. $packageSourcePath = $newPackageTempPath $zipContents = Get-ChildItem -Path $newPackageTempPath if ($zipContents -and $zipContents.GetType().Name -eq "DirectoryInfo") { $packageSourcePath = Join-Path $packageSourcePath $zipContents.Name } $packageDestinationPath = Join-Path $AndroidHome $installPath Move-FolderContentsWithRetry -Path $packageSourcePath -Destination $packageDestinationPath -Reason "Moving new package into place" # Make any required updates to source.properties Update-SourceProperties -PackageName $PackageName -InstallPath $installPath $newPackageInstalled = $true } catch { $innerException = Get-InnermostException -Exception $_.Exception Write-Host " - $($innerException.Message)" $result = $false # Output a list of running processes, which can be useful infomation in the case of access denied errors, for example Write-Host "`nRunning processes: $((Get-Process | Select-Object -ExpandProperty processname | Group-Object | % { "$($_.Name) ($($_.Count))" }) -join ", ")" } finally { Write-Host "- Cleaning up..." if ($existingPackageBackedUp -and -not $newPackageInstalled) { # If we succeeded in backing up the existing package, but failed to install the new one, try to move the existing package back. try { Move-FolderContentsWithRetry -Path $currentPackageTempPathPackageFolder -Destination $targetInstallFolder -Reason "Restoring existing package" } catch { $innerException = Get-InnermostException -Exception $_.Exception Write-Host " - WARNING: Restoring existing package failed: $($innerException.Message)" $result = $false # presumably this will already have been set, but good to be sure } } if ($currentPackageTempPath) { Write-Host " - Removing temporary folder created to back up existing package" Remove-Folder $currentPackageTempPath } if ($newPackageTempPath) { Write-Host " - Removing temporary folder created to unzip new package" Remove-Folder $newPackageTempPath } } return $result } Function Get-InstallRoot([string]$PackageName) { # Determines the install root folder from the package name (note this only works for package types we currently care about). if ($PackageName -eq "tools" -or $PackageName -eq "platform-tools" -or $PackageName -eq "emulator") { return $PackageName } if ($PackageName.StartsWith("android-")) { return "platforms\$PackageName" } if ($PackageName.StartsWith("addon-")) { return "add-ons\$PackageName" } $packageNameArray = $PackageName.split("-") if ($PackageName.StartsWith("extra-")) { return "extras\$($packageNameArray[1])\$($packageNameArray[2])" } if ($PackageName.StartsWith("build-tools-")) { return "build-tools\$($packageNameArray[2])" } if ($PackageName.StartsWith("cmdline-tools-")) { return "cmdline-tools\$($packageNameArray[2])" } if ($PackageName.StartsWith("sys-img-")) { $apiLevel = $packageNameArray[$packageNameArray.Length - 1] $type = $packageNameArray[$packageNameArray.Length - 2] if ($type -eq "android") { $type = "default" } $proc = $packageNameArray[2..($packageNameArray.Length - 3)] -join "-" return "system-images\android-$apiLevel\$type\$proc" } throw "Unknown package type: $PackageName" } Function Uninstall-Folder([string]$Path) { if (-not [System.IO.Directory]::Exists($Path)) { Write-Host "- WARNING: Path '$Path' does not exist or is not a directory." return } Write-Host "- Uninstalling folder $Path" Remove-Folder -Path $Path $parentPath = [System.IO.Directory]::GetParent($Path) while ((Get-ChildItem $parentPath -force).Count -eq 0) { Write-Host "- Removing empty folder $parentPath" Remove-Folder -Path $parentPath $parentPath = [System.IO.Directory]::GetParent($parentPath) } } Function Remove-Folder([string]$Path) { Remove-Item $Path -Recurse -Force -ErrorAction SilentlyContinue -ErrorVariable ErrorOut if ($ErrorOut) { # If it fails, it could be because of long paths. Fall back to ROBOCOPY trick # (which empties the directory, then we have to delete it again). $exception = Get-InnermostException -Exception $ErrorOut.Exception[0] Write-Host " - Removing folder '$Path' failed with error: $($exception.message)" Write-Host " - Trying again using ROBOCOPY." $emptyFolder = Create-TempFolder -Parent ([System.IO.Path]::GetTempPath()) robocopy $emptyFolder $path /MIR Remove-Item $Path -Recurse -Force -ErrorAction SilentlyContinue Remove-Item $emptyFolder -Recurse -Force -ErrorAction SilentlyContinue } } Function Update-SourceProperties([string]$PackageName, [string]$InstallPath) { # Some packages (like HAXM) don't include source.properties, so we write it out with enough information # that we don't try to update it again (version) and SDK Manager recognizes it. $sourcePropertiesPath = Join-Path $AndroidHome (Join-Path $InstallPath "source.properties") if (-not (Test-Path $sourcePropertiesPath)) { # When writing out Pkg.Revision for an addon package, we have probably been passed a version in the form "x.0.0" # (because we get passed a version in the same form as used for the Willow package, to keep Willow authoring simple). # However, Android SDK expects just a single number. So tweak that here. $packageRevision = $Version if ($PackageName.StartsWith("addon-") -and $packageRevision.EndsWith(".0.0")) { $packageRevision = $packageRevision.Split(".")[0] } Write-Host "- Writing Pkg.Revision=$packageRevision to source.properties" Add-Content $sourcePropertiesPath "Pkg.Revision=$packageRevision" # Determine if there are other properties we need to add for this package $packageNameArray = $PackageName.split("-") if ($packageNameArray[0] -eq "addon") { # For 'addon' packages, need to include AndroidVersion.ApiLevel, Addon.NameId and Addon.VendorId Add-SourceProperty -SourcePropertiesPath $sourcePropertiesPath -PropertyName "Addon.NameId" -PropertyValue $packageNameArray[1] Add-SourceProperty -SourcePropertiesPath $sourcePropertiesPath -PropertyName "Addon.VendorId" -PropertyValue $packageNameArray[2] Add-SourceProperty -SourcePropertiesPath $sourcePropertiesPath -PropertyName "AndroidVersion.ApiLevel" -PropertyValue $packageNameArray[3] } ElseIf ($packageNameArray[0] -eq "extra") { # For 'extra' packages, need to include Extra.VendorId if it isn't android $vendorId = $packageNameArray[1] if ($vendorId -ne "android") { Add-SourceProperty -SourcePropertiesPath $sourcePropertiesPath -PropertyName "Extra.VendorId" -PropertyValue $packageNameArray[1] } } } # The SDK Manager overwrites source.properties even if the package contains it. Usually what's in the package # is all we need, but sometimes it contains properties that confuse the SDK Manager (meaning it detects the # package as broken). Remove those if needed. if ($PackageName.StartsWith("sys-img")) { # For system images, need to remove Addon.VendorId $sourceProperties = (Get-Content $sourcePropertiesPath) -join "`n" $propertyToRemove = "Addon.VendorId" $removePropertyRegex = "$propertyToRemove=.+" $match = ([regex]::Matches($sourceProperties, $removePropertyRegex)) if ($match -and $match[0].Groups) { Write-Host "- Removing $($match[0].Groups[0].Value) from source.properties" $index = $match[0].Groups[0].Index $length = $match[0].Groups[0].Length + 1 # add 1 to remove line break $sourceProperties = $sourceProperties.remove($index,$length) } Set-Content -Path $sourcePropertiesPath -Value $sourceProperties } } Function Add-SourceProperty([string]$SourcePropertiesPath, [string]$PropertyName, [string]$PropertyValue) { Write-Host "- Writing $PropertyName=$PropertyValue to source.properties" Add-Content $sourcePropertiesPath "$PropertyName=$PropertyValue" } Function Get-CurrentPackageVersion([string]$PackageName, [string]$InstallPath) { Write-Host("Getting version of $PackageName with install path $InstallPath") $sourcePropertiesPath = Join-Path $AndroidHome (Join-Path $InstallPath "source.properties") if (Test-Path $sourcePropertiesPath) { $sourceProperties = Get-Content $sourcePropertiesPath $packageRevisionRegex = 'Pkg.Revision=([0-9.]+)' $packageRevision = ([regex]::Matches($sourceProperties, $packageRevisionRegex)) $packageRevision = If ($packageRevision -and $packageRevision[0].Groups) {$packageRevision[0].Groups[1].Value} Else {"0.0.0"} # Ensure we have 3 numbers $packageRevision = Get-ThreeDigitVerion -TestVersion $packageRevision Write-Host "- Currently installed version: $packageRevision" } else { Write-Host "- Not currently installed" $packageRevision = "0.0.0" } return New-Object System.Version $packageRevision } Function Get-ThreeDigitVerion([string]$TestVersion) { $versionArray = $TestVersion.split(".") while ($versionArray.Count -lt 3) { $versionArray += "0" } return $versionArray -join "." } Function Unzip-File([String]$Source, [String]$Destination) { $startTime = Get-Date Write-Host "- Expanding '$Source' to '$Destination'"; if ($PSVersionTable.PSVersion.Major -ge 3) { # Experience has shown that ZipFile.ExtractToDirectory() will sometimes fail because a target file gets locked # (by anti-virus software, typically). So we roll our own, retrying on failure. Add-Type -assembly "System.IO.Compression.FileSystem" $zipArchive = [System.IO.Compression.ZipFile]::OpenRead($Source) foreach ($zipArchiveEntry in $zipArchive.Entries) { $entryDestinationFilePath = [System.IO.Path]::Combine($Destination, $zipArchiveEntry.FullName) $entryDirectory = [System.IO.Path]::GetDirectoryName($entryDestinationFilePath) # Create the directory for this entry if (!(Test-Path $entryDirectory)) { New-Item -ItemType Directory -Path $entryDirectory | Out-Null } # If this entry is a file (as opposed to a directory), extract it if(!$entryDestinationFilePath.EndsWith("\") -and !$entryDestinationFilePath.EndsWith("/")) { Extract-ToFileWithRetry -ZipArchiveEntry $zipArchiveEntry -EntryDestinationFilePath $entryDestinationFilePath } } } else { # Failure because of locked files does not seem to be a problem with this approach, but it is *really* slow, so # we only use it if we have to. $shell = New-Object -com shell.application $zip = $shell.NameSpace($Source) $dest = $shell.NameSpace($Destination) # Option flags 4: No progress box, 16: Click Yes to All, 512: Don't Confirm new Dir, 1024: Suppress error UI $dest.CopyHere($zip.Items(), 4 + 16 + 512 + 1024) } Write-Host "- Expand took $((Get-Date).Subtract($startTime).TotalSeconds) second(s)" } Function Extract-ToFileWithRetry($ZipArchiveEntry, $EntryDestinationFilePath) { $i = 0 do { try { [System.IO.Compression.ZipFileExtensions]::ExtractToFile($ZipArchiveEntry, $EntryDestinationFilePath, $true); return } catch { Write-Host " - $($_.Exception.Message)" Write-Host " - Retrying." Start-Sleep -Milliseconds 1000 $i++ } } until ($i -ge 30) #30 seconds have passed and it's still failing. Try one last time without #catching the error so it gets thrown [System.IO.Compression.ZipFileExtensions]::ExtractToFile($ZipArchiveEntry, $EntryDestinationFilePath, $true); } Function Create-TempFolder($Parent, $Reason) { if (-not $Parent) { $Parent = [System.IO.Path]::GetTempPath() } # Passing a max length of 5, since that is the length of the shortest target folder ("tools"), so that our temp # path is never longer than the target path (so we don't introduce unnecessary max path problems) [string]$dirName = Get-RandomFileName -MaxLength 5 $targetTempPath = Join-Path $Parent $dirName if ($Reason) { Write-Host "- Creating temporary folder '$targetTempPath' for $Reason" } $createdTempPath = New-Item -ItemType Directory -Path $targetTempPath -ErrorAction SilentlyContinue -ErrorVariable ErrorOut if (-not $createdTempPath) { throw $ErrorOut.Exception } return $createdTempPath } Function Get-RandomFileName($MaxLength) { $randomFilename = [System.IO.Path]::GetFileNameWithoutExtension([System.IO.Path]::GetRandomFileName()) if ($MaxLength -and $randomFilename.Length -gt $MaxLength) { $randomFilename = $randomFilename.Substring(0, $MaxLength) } return $randomFilename } Function Move-FolderContentsWithRetry($Path, $Destination, $Reason) { $i = 0 do { try { Move-FolderContents -Path $Path -Destination $Destination -Reason $Reason return } catch { Write-Host " - $($_.Exception.Message)" Write-Host " - Retrying." $i++ } } until ($i -ge 30) #30 seconds have passed and it's still failing. Try one last time without #catching the error so it gets thrown Move-FolderContents -Path $Path -Destination $Destination -Reason $Reason } Function Move-FolderContents($Path, $Destination, $Reason) { Write-Host "- $($Reason): Moving folder contents from '$Path' to '$Destination'" # Wait a second before trying to move a folder's contents, to help ensure previous actions are fully processed. Start-Sleep -Milliseconds 1000 if (!(Test-Path $Destination)) { New-Item -ItemType Directory -Path $Destination -ErrorAction SilentlyContinue -ErrorVariable ErrorOut if ($ErrorOut) { throw $ErrorOut.Exception } } Get-ChildItem -Path $Path | Move-Item -Destination $Destination -ErrorAction SilentlyContinue -ErrorVariable ErrorOut if ($ErrorOut) { throw $ErrorOut.Exception } } Function Move-FolderWithRetry($Path, $Destination, $Reason) { $i = 0 do { try { Move-Folder -Path $Path -Destination $Destination -Reason $Reason return } catch { Write-Host " - $($_.Exception.Message)" Write-Host " - Retrying." $i++ } } until ($i -ge 30) #30 seconds have passed and it's still failing. Try one last time without #catching the error so it gets thrown Move-Folder -Path $Path -Destination $Destination -Reason $Reason } Function Move-Folder($Path, $Destination, $Reason) { Write-Host "- $($Reason): Moving folder '$Path' to '$Destination'" # Wait a second before trying to move a folder, to help ensure previous actions are fully processed. Start-Sleep -Milliseconds 1000 if (!(Test-Path $Destination)) { New-Item -ItemType Directory -Path $Destination -ErrorAction SilentlyContinue -ErrorVariable ErrorOut if ($ErrorOut) { throw $ErrorOut.Exception } } Move-Item -Path $Path -Destination $Destination -ErrorAction SilentlyContinue -ErrorVariable ErrorOut if ($ErrorOut) { throw $ErrorOut.Exception } } Function Get-InnermostException($Exception) { if ($Exception.InnerException -and $Exception.InnerException -ne $Exception) { return Get-InnermostException -Exception $Exception.InnerException } return $Exception } Function Kill-ADB { # We need to kill adb process before installing packages, otherwise it can cause an access violation, # and after installing, otherwise it can cause the setup process to stop responding. Also, need to have -erroraction # silentlycontinue, otherwise we'll get an error when adb doesn't exist. $processAdb = Get-Process adb -erroraction silentlycontinue if ($processAdb) { Write-Host "- Stopping ADB process" $processAdb.Kill() } } Function Get-AVDConfiguration([String]$FilePath) { $result = @{} if (Test-Path $FilePath) { ForEach ($pair in (Get-Content $FilePath) -split "`n") { $pair = $pair -split "=" if ($pair.Count -eq 2) { $result[$pair[0]] = $pair[1] } } } return $result } Function Set-AVDConfiguration([String]$FilePath, [Hashtable]$configHashtable) { Remove-Item $FilePath ForEach ($key in $configHashtable.Keys | Sort-Object) { $keyValuePair = "$key=$($configHashtable[$key])" Add-Content $FilePath $keyValuePair } } Function Get-AVDPath([string]$AVDName, [string]$AndroidBatch) { $packageRegex = "Path: ((?:.*)\\$AVDName.avd)" [array]$avdListArray = & $AndroidBatch list avd $avdListString = ($avdListArray -join "`n") $availablePackages = [regex]::Matches($avdListString, $packageRegex) if ($availablePackages.Count -eq 0) { return $null; } return $availablePackages[0].Groups[1]; } Function Create-AVD([string]$AndroidBatch, [string]$Name, [string]$ABI, [string]$Target, [hashtable]$ConfigurationOptions) { if (-not $Name -or -not $ABI -or -not $Target) { return } Write-Host "- Creating AVD '$Name'" $processArgs = @("create avd", "-n $Name", "-t $Target", "-b $ABI", "--sdcard 512M", "--force") # Create the AVD $process = Invoke-InteractiveProcess ` -FilePath "$AndroidBatch" ` -ArgumentList $processArgs Write-Host " - Command: ""$AndroidBatch"" $processArgs" while (-not $process.StandardOutput.EndOfStream) { # Answer 'no' to: Do you wish to create a custom hardware profile [no] $firstChar = $process.StandardOutput.Peek() if ($firstChar -eq 68) { $process.StandardInput.WriteLine("no") } $line = $process.StandardOutput.ReadLine() Write-Host " - $line" } Cleanup -Process $process $avdPath = Get-AVDPath -AVDName $Name -AndroidBatch $AndroidBatch if ($avdPath) { $avdConfigFile = "$avdPath\config.ini" if (Test-Path $avdConfigFile) { $configHashtable = Get-AVDConfiguration $avdConfigFile foreach ($key in $ConfigurationOptions.Keys) { $configHashtable[$key] = $ConfigurationOptions[$key] } Set-AVDConfiguration $avdConfigFile $configHashtable Write-Host " - Updating AVD '$Name' to the following hardware config:$([Environment]::NewLine)" Get-Content $avdConfigFile Write-Host "$([Environment]::NewLine)" } } } ################################################################################ #Xamarin methods - separated to invoke the new avdmanager instead of android.bat Function Get-JavaHome { Write-Host "Getting JDK value." #try to locate private Eclipse Foundation JDK 8 $javaHome = Get-OpenJDK "Android" "jdk" if(($javaHome -ne $null) -and (Test-Path "$javaHome")) { Write-Host("Detected OpenJDK at $javaHome") return $javaHome } #try to find Microsoft OpenJDK 11 # Disabled until all installation processes run under JDK 11 #$javaHome = Get-OpenJDK "Microsoft" "" #if(($javaHome -ne $null) -and (Test-Path "$javaHome")) #{ # Write-Host("Detected OpenJDK at $javaHome") # return $javaHome #} Write-Host("Default OpenJDK distributions not located.") #fallback on Oracle JDK - two ways $javaHome = (Get-ItemProperty -Path "HKLM:\SOFTWARE\WOW6432Node\JavaSoft\Java Development Kit\1.8" -Name JavaHome -ErrorAction SilentlyContinue -ErrorVariable jdkError).JavaHome if(($javaHome -ne $null) -and (Test-Path "$javaHome")) { Write-Host("Falling back on 64bit Oracle JDK in WOW6432Node at $javaHome") return $javaHome } else { Write-Host("OracleJDK detection for 64bit failed with: $jdkError") $javaHome = (Get-ItemProperty -Path "HKLM:\SOFTWARE\JavaSoft\Java Development Kit\1.8" -Name JavaHome -ErrorAction SilentlyContinue -ErrorVariable jdkError).JavaHome if(($javaHome -ne $null) -and (Test-Path "$javaHome")) { Write-Host("Falling back on 32bit Oracle JDK at $javaHome") return $javaHome } else { Write-Host("OracleJDK detection for 32bit failed with: $jdkError") #if no valid JDK at any location, return an error Write-Host("Error: No JDK detected. Please do a repair install or install JDK manually") exit 3 } } } Function Get-OpenJDK ([string]$pathVendor, [string]$subPathVendor){ $Arch = (Get-WmiObject Win32_OperatingSystem).OSArchitecture if ($Arch -like '64*') { $ProgramFiles=[Environment]::GetEnvironmentVariable("ProgramW6432") Write-Host("Using 64-bit Program Files at $ProgramFiles") } else { $ProgramFiles=[Environment]::GetEnvironmentVariable("ProgramFiles") Write-Host("Using 32-bit Program Files at $ProgramFiles") } $Versions = New-Object System.Collections.Generic.List[System.Object] $rootPathAndroid = Join-Path -Path $ProgramFiles -ChildPath $pathVendor $rootPath = Join-Path -Path $rootPathAndroid -ChildPath $subPathVendor if (Test-Path $rootPath) { $jdkPaths = (Get-ChildItem -Path $rootPath | ?{ $_.PSIsContainer } | Select -expand Name) foreach ($path in $jdkPaths) { if($path -match '^jdk-(?(?:(\d+)\.)?(?:(\d+)\.)?(?:(\d+)\.\d+))(?:-.*)') { $Versions.Add($Matches.Ver) } } $OpenJDKVersion = $Versions | Sort-Object | Select-Object -Last 1 $filteredJdkFolder = $jdkPaths | ?{ $_ -match $OpenJDKVersion } | Select-Object -Last 1 $filteredJdkPath = Get-ChildItem -Path (Join-Path -Path $rootPath -ChildPath $filteredJdkFolder) -Include "jre" -Directory -Recurse | %{$_.Parent.FullName} | Select-Object -First 1 return $filteredJdkPath } else { Write-Host("$rootPath is not a valid location on this system") } } Function Get-AVDPath-Xamarin([string]$AVDName, [string]$AvdManager) { $packageRegex = "Path: ((?:.*)\\$AVDName.avd)" [array]$avdListArray = & $AvdManager list avd $avdListString = ($avdListArray -join "`n") $availablePackages = [regex]::Matches($avdListString, $packageRegex) if ($availablePackages.Count -eq 0) { return $null; } return $availablePackages[0].Groups[1]; } Function Create-AVD-Xamarin([string]$AvdManager, [string]$Name, [string]$ABI, [string]$Target, [string]$Chipset, [hashtable]$ConfigurationOptions) { if (-not $Name -or -not $ABI -or -not $Target -or -not $Chipset) { Write-Host "Missing parameters passed to AVD creation method; AVD could not be created: `n" + ` "* Name: $Name `n" + ` "* ABI: $ABI `n" + ` "* Target: $Target `n" + ` "* Chipset: $Chipset " return } #Command is in the form of: #avdmanager -v create avd -n NAME -k “system-image;android-27;google_apis;x86” -c 512M -f $SdkId = "`"system-images;$Target;$ABI;$Chipset`"" Write-Host "- Creating AVD '$Name'" $processArgs = @("-v", "create avd", "-n $Name", "-k $SdkId", "-c 512M", "-f") # Create the AVD $process = Invoke-InteractiveProcess ` -FilePath "$AvdManager" ` -ArgumentList $processArgs Write-Host " - Command: ""$AvdManager"" $processArgs" while (-not $process.StandardOutput.EndOfStream) { # Answer 'no' to: Do you wish to create a custom hardware profile [no] $firstChar = $process.StandardOutput.Peek() if ($firstChar -eq 68) { $process.StandardInput.WriteLine("no") } $line = $process.StandardOutput.ReadLine() Write-Host " - $line" } Cleanup -Process $process $avdPath = Get-AVDPath-Xamarin -AVDName $Name -AvdManager $AvdManager if ($avdPath) { $avdConfigFile = "$avdPath\config.ini" if (Test-Path $avdConfigFile) { $configHashtable = Get-AVDConfiguration $avdConfigFile foreach ($key in $ConfigurationOptions.Keys) { $configHashtable[$key] = $ConfigurationOptions[$key] } Set-AVDConfiguration $avdConfigFile $configHashtable Write-Host " - Updating AVD '$Name' to the following hardware config:$([Environment]::NewLine)" Get-Content $avdConfigFile Write-Host "$([Environment]::NewLine)" } } } # End of Xamarin helper methods ################################################################################ Function Get-CannotInstallHaxmReason { $PF_VIRT_FIRMWARE_ENABLED = 21 if (-not (Get-IsProcessorFeaturePresent $PF_VIRT_FIRMWARE_ENABLED)) { return "Intel HAXM requires hardware virtualization, which is not available. This could be because:`n" + ` "* Your hardware does not support hardware virtualization.`n" + ` "* Hardware virtualization is not enabled in your BIOS.`n" + ` "* You are running in a virtual machine.`n" + ` "* Hyper-V or DeviceGuard is running." } $ProcessorManufacturer = (Get-Item HKLM:\HARDWARE\DESCRIPTION\System\CentralProcessor\0).GetValue("VendorIdentifier") if ($ProcessorManufacturer -ne "GenuineIntel") { return "Intel HAXM requires an Intel processor. This machine reports the manufacturer as '$ProcessorManufacturer'." } $PF_NX_ENABLED = 12 if (-not (Get-IsProcessorFeaturePresent $PF_NX_ENABLED)) { return "Intel HAXM requires the Execute Disable bit enabled. It is either not supported by your hardware, or not enabled in your BIOS." } return $null } Function Get-IsProcessorFeaturePresent([uint32] $processorFeature) { $assemblyName = New-Object System.Reflection.AssemblyName("Kernel32Lib") $assembly = [AppDomain]::CurrentDomain.DefineDynamicAssembly($assemblyName, "Run") $module = $assembly.DefineDynamicModule("Kernel32Lib", $False) $type = $module.DefineType("Kernel32", "Public, Class") $method = $type.DefineMethod( "IsProcessorFeaturePresent", "Public, Static", [Bool], [Type[]] @([uint32])) $ctor = [Runtime.InteropServices.DllImportAttribute].GetConstructor(@([String])) $attr = New-Object Reflection.Emit.CustomAttributeBuilder $ctor, @("kernel32.dll") $method.SetCustomAttribute($attr) $kernel32 = $type.CreateType() return $kernel32::IsProcessorFeaturePresent($processorFeature) } Function Get-IsHaxmInstalled { $HaxmServiceInfo = Get-Service -Name IntelHaxm -ErrorAction SilentlyContinue return [boolean]$HaxmServiceInfo } Function Cleanup([System.Diagnostics.Process]$Process) { # We need to kill adb process after installing packages, otherwise it can cause the setup proces to stop responding. # need to have -erroraction silentlycontinue, otherwise we'll get an error when adb doesn't exist. $processAdb = Get-Process adb -erroraction silentlycontinue if ($processAdb) { $processAdb.Kill() } if (!$Process.HasExited) { $Process.CloseMainWindow() } $Process.Dispose() } # INPUT: # [String]$Package, # [String]$FileName, # [String]$Version, # [String]$Operation, # [String[]]$RequestedAVDs, # [String]$AndroidHome # Get Start Time $startDTM = (Get-Date) $sdkInstallLogMessage = "AndroidSDKInstall: -Package $Package -FileName $FileName -Version $Version -Operation $Operation" if ($RequestedAVDs) { $sdkInstallLogMessage += " -RequestedAVDs $RequestedAVDs" } Write-Host $sdkInstallLogMessage Write-Host "Android SDK Install starting ..." if (-not $AndroidHome) { $AndroidHome = Get-AndroidHomeFromRegistry if (!$AndroidHome) { Write-Host "Error: No Android SDK detected." exit 3 } } $haxmPackage = "extra-intel-Hardware_Accelerated_Execution_Manager" $sdkToolsPackage = "tools" Write-Host "AndroidHome: $AndroidHome" Write-Host "Windows version: $([System.Environment]::OSVersion.Version) ($((Get-WmiObject -Class Win32_OperatingSystem -ea 0).OSArchitecture))" Write-Host "PowerShell version: $($PSVersionTable.PSVersion)" if (!$PSScriptRoot) { $PSScriptRoot = Split-Path $script:MyInvocation.MyCommand.Path } if ($Operation -eq "Uninstall") { # Uninstall will remove the Android SDK package if it is the expected version, but it does't uninstall HAXM or delete AVDs Uninstall-Package -PackageName $Package -Version $Version exit 0 } $haxmRequested = $Package -eq $haxmPackage $skipHaxmReason = $null if ($haxmRequested) { # Don't try to download or install HAXM if this machine doesn't support it $skipHaxmReason = Get-CannotInstallHaxmReason if (-not $skipHaxmReason -and $Operation -ne "Repair" -and (Get-IsHaxmInstalled)) { # If HAXM is already installed, don't try to download it (that is, don't ask Android SDK # to "install" it), unless we're doing a repair. $skipHaxmReason = "Intel HAXM is already installed." } } $startTime = Get-Date if ($haxmRequested -and $skipHaxmReason) { Write-Host "`nSkipping package $($haxmPackage): $skipHaxmReason" } else { $result = Install-Package -PackageName $Package -Operation $Operation # Kill ADB process to prevent the setup becoming unresponsive Kill-ADB if ($result -eq $false) { Write-Host "`nError: The package failed to install" exit 1 } } Write-Host "`nAndroid SDK package successfully updated" Write-Host "Elapsed time: $((Get-Date).Subtract($startTime).TotalSeconds) second(s)" if ($haxmRequested -and -not $skipHaxmReason) { # Since "installing" HAXM using the Android SDK just downloads the installer, we now have to run it. # But only if it isn't already installed, or repair was requested. $haxmPath = "$AndroidHome\extras\intel\Hardware_Accelerated_Execution_Manager" Write-Host "`nRunning Intel HAXM installer..." $haxmInstallProcess = Start-Process -WorkingDirectory $haxmPath -FilePath silent_install.bat -Wait -PassThru -WindowStyle Hidden -ArgumentList $("-log", "output.log") -ErrorAction SilentlyContinue # Might be null if Android SDK Manager install process above failed for some reason if ($haxmInstallProcess) { # Write content of HAXM installer output to our log, ignoring blank lines and start and end times $haxmLog = Get-Content $haxmPath\output.log -ErrorAction SilentlyContinue $processedHaxmLog = "" if ($haxmLog) { ForEach ($haxmLogLine in $haxmLog) { if ($haxmLogLine.StartsWith("=== Logging stopped")) { break } if ($haxmLogLine -and -not $haxmLogLine.StartsWith("==")) { if (-not $processedHaxmLog) { $processedHaxmLog = ">> $haxmLogLine" } else { $processedHaxmLog = $processedHaxmLog + "`n>> $haxmLogLine" } } } } if ($processedHaxmLog) { Write-Host "Intel HAXM installer log:" Write-Host $processedHaxmLog } if ($haxmInstallProcess.ExitCode -eq 0) { Write-Host "Intel HAXM install successful." } else { Write-Host "Intel HAXM install failed." } } } # If specific AVDs are requested, create them if they don't already exist if ($RequestedAVDs) { Write-Host "Creating requested AVDs:" $configurationOptions = @{"avd.ini.encoding" = "UTF-8"; "disk.dataPartition.size" = "800M"; "hw.accelerometer" = "yes"; "hw.audioInput" = "yes"; "hw.audioOutput" = "yes"; "hw.battery" = "yes"; "hw.camera.back" = "emulated"; "hw.camera.front" = "emulated"; "hw.dPad" = "no"; "hw.gps" = "yes"; "hw.gpu.enabled" = "yes"; "hw.gpu.mode" = "host"; "hw.initialOrientation" = "Portrait"; "hw.keyboard" = "yes"; "hw.lcd.density" = "480"; "hw.mainKeys" = "yes"; "hw.ramSize" = "512"; "hw.sdCard" = "yes"; "hw.sensors.orientation" = "yes"; "hw.sensors.proximity" = "yes"; "hw.trackBall" = "yes"; "runtime.network.latency" = "none"; "runtime.network.speed" = "full"; "sdcard.size" = "512M"; "showDeviceFrame" = "yes"; "skin.dynamic" = "no"; "tag.display" = "Google APIs"; "tag.id" = "google_apis"; "vm.heapSize" = "64"} #Check for sdk tools version so we know what script to call $installPath = Get-InstallRoot -PackageName $sdkToolsPackage $sdkToolsVersion = Get-CurrentPackageVersion -PackageName $sdkToolsPackage -InstallPath $installPath #Get JDK location so we can use it to set JAVA_HOME later Write-Host("Getting JDK location") $JavaHome = Get-JavaHome if ($sdkToolsVersion.Major -ge 26) { Write-Host "SDK tools $sdkToolsVersion is 26 or greater - using new avdmanager" # set JAVA_HOME for process level [environment]::SetEnvironmentVariable("JAVA_HOME", $JavaHome, [System.EnvironmentVariableTarget]::Process) $avdManager = Join-Path $AndroidHome "tools\bin\avdmanager.bat" if (-not (Test-Path $avdManager)) { Write-Host "Error: Unable to create AVDs - $avdManager not found" exit 2 } # If we're not repairing, only create AVDs that don't already exist if ($Operation -ne "Repair") { [array]$existingAVDs = & $avdManager list avd -c } ForEach ($avd in $RequestedAVDs) { $avd = $avd.split("\") $deviceType = $avd[0] #ex: phone $avdAbi = $avd[1] #ex: google_apis $avdTarget = $avd[3] #ex: android-27 $avdChipset = $avd[4] #ex: x86 $avdName = $avd[5] if ($Operation -ne "Repair" -and $existingAVDs -icontains $avdName) { Write-Host "- Skipping creating AVD '$avdName' as it already exists" } else { $configurationOptions["skin.name"] = $avd[2] $configurationOptions["skin.path"] = $avd[2] Create-AVD-Xamarin ` -AvdManager $avdManager ` -Name $avdName ` -ABI $avdAbi ` -Target $avdTarget ` -Chipset $avdChipset ` -ConfigurationOptions $configurationOptions } } } #Cordova and old SDK tools code path follows else { Write-Host "SDK tools $sdkToolsVersion is less than 26 - falling back on android.bat" # If JAVA_HOME is not set for system or is invalid, set it for MDD. $java_home = [Environment]::GetEnvironmentVariable("JAVA_HOME", "Machine") if (($java_home -eq $null) -Or (-not (Test-Path $java_home))) { Write-Host("Setting JAVA_HOME environment variable") [environment]::SetEnvironmentVariable("JAVA_HOME", $JavaHome, [System.EnvironmentVariableTarget]::Machine) } else { Write-Host("Found valid JAVA_HOME environment variable with value $java_home") } # Set JAVA_HOME for process level as the following scripts look for JAVA_HOME. [environment]::SetEnvironmentVariable("JAVA_HOME", $JavaHome, [System.EnvironmentVariableTarget]::Process) $androidBatch = Join-Path $AndroidHome "tools\android.bat" if (-not (Test-Path $androidBatch)) { Write-Host "Error: Unable to create AVDs - $androidBatch not found" exit 2 } # If we're not repairing, only create AVDs that don't already exist if ($Operation -ne "Repair") { [array]$existingAVDs = & $androidBatch list avd -c } ForEach ($avd in $RequestedAVDs) { # Each AVD should be provided in the form device\abi\skin\target\chipset\name (for example, # "phone\google_apis/x86\768x1280\android-23\x86\Android_Accelerated_x86" or "tablet\google_apis/armeabi-v7a\768x1280\android-23\arm") $avd = $avd.split("\") $deviceType = $avd[0] $avdAbi = $avd[1] $avdTarget = $avd[3] $avdChipset = $avd[4] $avdName = "VisualStudio_$($avdTarget)_$($avdChipset)_$deviceType" if ($Operation -ne "Repair" -and $existingAVDs -icontains $avdName) { Write-Host "- Skipping creating AVD '$avdName' as it already exists" } else { $configurationOptions["skin.name"] = $avd[2] $configurationOptions["skin.path"] = $avd[2] Create-AVD ` -AndroidBatch $androidBatch ` -Name $avdName ` -ABI $avdAbi ` -Target $avdTarget ` -ConfigurationOptions $configurationOptions } } } } Write-Host "`nAndroid SDK Install is successful." # Get End Time $endDTM = (Get-Date) Write-Host "Elapsed Time: $(($endDTM-$startDTM).totalseconds) seconds" exit 0 # SIG # Begin signature block # MIIjkgYJKoZIhvcNAQcCoIIjgzCCI38CAQExDzANBglghkgBZQMEAgEFADB5Bgor # BgEEAYI3AgEEoGswaTA0BgorBgEEAYI3AgEeMCYCAwEAAAQQH8w7YFlLCE63JNLG # KX7zUQIBAAIBAAIBAAIBAAIBADAxMA0GCWCGSAFlAwQCAQUABCDPrmQp3rf+N+p7 # IgG8l/mwEB5Ra+LwZgS+NVe7wCtwZ6CCDYEwggX/MIID56ADAgECAhMzAAAB32vw # LpKnSrTQAAAAAAHfMA0GCSqGSIb3DQEBCwUAMH4xCzAJBgNVBAYTAlVTMRMwEQYD # VQQIEwpXYXNoaW5ndG9uMRAwDgYDVQQHEwdSZWRtb25kMR4wHAYDVQQKExVNaWNy # b3NvZnQgQ29ycG9yYXRpb24xKDAmBgNVBAMTH01pY3Jvc29mdCBDb2RlIFNpZ25p # bmcgUENBIDIwMTEwHhcNMjAxMjE1MjEzMTQ1WhcNMjExMjAyMjEzMTQ1WjB0MQsw # CQYDVQQGEwJVUzETMBEGA1UECBMKV2FzaGluZ3RvbjEQMA4GA1UEBxMHUmVkbW9u # ZDEeMBwGA1UEChMVTWljcm9zb2Z0IENvcnBvcmF0aW9uMR4wHAYDVQQDExVNaWNy # b3NvZnQgQ29ycG9yYXRpb24wggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIB # AQC2uxlZEACjqfHkuFyoCwfL25ofI9DZWKt4wEj3JBQ48GPt1UsDv834CcoUUPMn # s/6CtPoaQ4Thy/kbOOg/zJAnrJeiMQqRe2Lsdb/NSI2gXXX9lad1/yPUDOXo4GNw # PjXq1JZi+HZV91bUr6ZjzePj1g+bepsqd/HC1XScj0fT3aAxLRykJSzExEBmU9eS # yuOwUuq+Cri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