param( [string]$JavaHome = $env:JAVA_HOME, [string]$AndroidSdk = "$env:LOCALAPPDATA\Android\Sdk" ) $ErrorActionPreference = 'Stop' if ([string]::IsNullOrWhiteSpace($JavaHome)) { throw 'Set JAVA_HOME or pass -JavaHome with a JDK 17 installation.' } $env:JAVA_HOME = $JavaHome $env:ANDROID_HOME = $AndroidSdk if (!(Test-Path -LiteralPath (Join-Path $JavaHome 'bin\java.exe'))) { throw 'Pass -JavaHome with a JDK 17 installation.' } Push-Location $PSScriptRoot try { & '.\gradlew.bat' --no-daemon assembleDebug lintDebug if ($LASTEXITCODE -ne 0) { throw "Android build failed ($LASTEXITCODE)" } $apk = Join-Path $PSScriptRoot 'app\build\outputs\apk\debug\app-debug.apk' $dest = Join-Path $PSScriptRoot 'artifacts\RTOS-Phone-Bridge-0.3.0-debug.apk' New-Item -ItemType Directory -Force -Path (Split-Path $dest) | Out-Null Copy-Item -LiteralPath $apk -Destination $dest -Force Get-FileHash -LiteralPath $dest -Algorithm SHA256 } finally { Pop-Location }