20 lines
1.0 KiB
PowerShell
20 lines
1.0 KiB
PowerShell
param([switch]$WithEmulator)
|
|
$ErrorActionPreference = 'Stop'
|
|
foreach ($taskToolName in @('flutter', 'java', 'android-cli')) {
|
|
& (Join-Path $PSScriptRoot 'install-tool.ps1') -Tool $taskToolName
|
|
if ($LASTEXITCODE -ne 0) { throw "Tool setup failed: $taskToolName" }
|
|
}
|
|
. (Join-Path $PSScriptRoot 'android-env.ps1')
|
|
& (Join-Path $PSScriptRoot 'setup-android-sdk.ps1') -WithEmulator:$WithEmulator
|
|
if ($WithEmulator) { & (Join-Path $PSScriptRoot 'create-android-emulator.ps1') }
|
|
& flutter.bat config --android-sdk $env:ANDROID_HOME --jdk-dir $env:JAVA_HOME --no-analytics
|
|
if ($LASTEXITCODE -ne 0) { throw 'Flutter configuration failed.' }
|
|
$taskDoctorLog = Join-Path $taskToolRoot 'flutter-doctor.txt'
|
|
& flutter.bat doctor -v *> $taskDoctorLog
|
|
$taskDoctorExit = $LASTEXITCODE
|
|
$taskDoctorText = Get-Content -Raw -LiteralPath $taskDoctorLog
|
|
Write-Output $taskDoctorText
|
|
if ($taskDoctorExit -ne 0 -or $taskDoctorText -notmatch '\[√\] Android toolchain') {
|
|
throw 'Android toolchain verification has not passed; inspect the doctor output.'
|
|
}
|