fix(skills): harden deploy scripts for GPU and timing issues
android-dev.ps1: - Changed GPU mode from 'auto' to 'guest' (host/auto/swiftshader/angle all fail with 'OpenGL Core Profile not supported' on this machine) - Added -no-snapshot-load flag (prevents corrupt snapshot issues) - Increased PackageManager wait from 5s to 30s (PM needs ~30s after sys.boot_completed=1 before adb install succeeds) - Replaced blocking 'adb wait-for-device' with polling loop (120s timeout) - Improved emulator-stop with force-kill fallback for hung processes - Simplified screenshot action: exec-out screencap instead of push/pull/rm - Made all timing values configurable via variables at top of script android-emulator SKILL.md: - Updated manual start command to use -gpu guest - Updated PM wait time reference from 5s to 30s - Added known issue #3: OpenGL Core Profile not supported (documents symptoms, affected GPU modes, and workaround)
This commit is contained in:
parent
c818b0d46e
commit
a9a999fd1e
2 changed files with 52 additions and 18 deletions
53
.github/skills/android-build/android-dev.ps1
vendored
53
.github/skills/android-build/android-dev.ps1
vendored
|
|
@ -55,9 +55,12 @@ $EMULATOR = "$SDK_ROOT\emulator\emulator.exe"
|
|||
$PROJECT_DIR = $PSScriptRoot | Split-Path | Split-Path | Split-Path # .github/skills/android-build → repo root
|
||||
$APK_PATH = "$PROJECT_DIR\app\build\outputs\apk\debug\app-debug.apk"
|
||||
$AVD_NAME = "S24Ultra_API35"
|
||||
$GPU_MODE = "guest" # 'guest' = Software-Rendering im Gast (host/auto/swiftshader scheitern an fehlendem OpenGL Core Profile)
|
||||
$PACKAGE = "de.krisenvorrat.app"
|
||||
$ACTIVITY = "$PACKAGE/.MainActivity"
|
||||
$BOOT_TIMEOUT = 300 # Sekunden (erster Boot eines neuen AVD kann >2min dauern)
|
||||
$ADB_CONNECT_TIMEOUT = 120 # Sekunden auf ADB-Verbindung warten
|
||||
$PM_WAIT = 30 # Sekunden nach Boot auf PackageManager warten
|
||||
$INSTALL_RETRY = 3
|
||||
|
||||
$env:ANDROID_HOME = $SDK_ROOT
|
||||
|
|
@ -141,10 +144,23 @@ function Start-Emulator {
|
|||
return $true
|
||||
}
|
||||
|
||||
Write-Step "Emulator starten: $AVD_NAME"
|
||||
Start-Process -FilePath $EMULATOR -ArgumentList "-avd $AVD_NAME -gpu auto" -WindowStyle Normal
|
||||
Write-Step "Warte auf ADB-Verbindung..."
|
||||
& $ADB wait-for-device
|
||||
Write-Step "Emulator starten: $AVD_NAME (GPU: $GPU_MODE)"
|
||||
Start-Process -FilePath $EMULATOR -ArgumentList "-avd $AVD_NAME -gpu $GPU_MODE -no-snapshot-load" -WindowStyle Normal
|
||||
|
||||
Write-Step "Warte auf ADB-Verbindung (max ${ADB_CONNECT_TIMEOUT}s)..."
|
||||
$connectElapsed = 0
|
||||
do {
|
||||
Start-Sleep -Seconds 5
|
||||
$connectElapsed += 5
|
||||
$connected = Test-DeviceConnected 'emulator'
|
||||
if ($connectElapsed % 15 -eq 0) { Write-Host " ... ${connectElapsed}s" -ForegroundColor DarkGray }
|
||||
} while (-not $connected -and $connectElapsed -lt $ADB_CONNECT_TIMEOUT)
|
||||
|
||||
if (-not $connected) {
|
||||
Write-Err "Emulator nicht erreichbar nach ${ADB_CONNECT_TIMEOUT}s. Prüfe GPU-Treiber und Hypervisor."
|
||||
return $false
|
||||
}
|
||||
Write-Ok "ADB verbunden nach ${connectElapsed}s"
|
||||
|
||||
Write-Step "Warte auf Boot (max ${BOOT_TIMEOUT}s)..."
|
||||
$elapsed = 0
|
||||
|
|
@ -161,10 +177,11 @@ function Start-Emulator {
|
|||
}
|
||||
|
||||
# Extra-Pause für PackageManager-Initialisierung
|
||||
Write-Step "Warte 5s auf PackageManager..."
|
||||
Start-Sleep -Seconds 5
|
||||
# PackageManager braucht deutlich länger als sys.boot_completed anzeigt
|
||||
Write-Step "Warte ${PM_WAIT}s auf PackageManager..."
|
||||
Start-Sleep -Seconds $PM_WAIT
|
||||
|
||||
Write-Ok "Emulator gebootet nach ${elapsed} Sekunden"
|
||||
Write-Ok "Emulator gebootet nach ${elapsed}s + ${PM_WAIT}s PM-Wait"
|
||||
return $true
|
||||
}
|
||||
|
||||
|
|
@ -246,6 +263,15 @@ switch ($Action) {
|
|||
'emulator-stop' {
|
||||
Write-Step "Emulator beenden"
|
||||
& $ADB emu kill 2>$null
|
||||
Start-Sleep -Seconds 3
|
||||
# Fallback: Prozesse killen falls emu kill nicht wirkt
|
||||
$remaining = Get-Process -Name "qemu-system*", "emulator" -ErrorAction SilentlyContinue
|
||||
if ($remaining) {
|
||||
Write-Warn "Emulator-Prozess reagiert nicht auf emu kill. Force-Kill..."
|
||||
$remaining | Stop-Process -Force -ErrorAction SilentlyContinue
|
||||
Start-Sleep -Seconds 2
|
||||
}
|
||||
Stop-Process -Name "crashpad*" -Force -ErrorAction SilentlyContinue
|
||||
Write-Ok "Emulator gestoppt"
|
||||
exit 0
|
||||
}
|
||||
|
|
@ -331,15 +357,12 @@ switch ($Action) {
|
|||
if (-not (Test-Path $tmpDir)) { New-Item -ItemType Directory -Path $tmpDir -Force | Out-Null }
|
||||
$timestamp = Get-Date -Format "yyyyMMdd-HHmmss"
|
||||
$filename = "screenshot-$timestamp.png"
|
||||
Write-Step "Screenshot: $filename"
|
||||
$screenshotPath = "$tmpDir\$filename"
|
||||
& $ADB $flags shell screencap -p "/sdcard/$filename"
|
||||
$ErrorActionPreference = 'Continue'
|
||||
$pullResult = & $ADB $flags pull "/sdcard/$filename" $screenshotPath 2>&1 | Out-String
|
||||
& $ADB $flags shell rm "/sdcard/$filename" 2>&1 | Out-Null
|
||||
$ErrorActionPreference = 'Stop'
|
||||
if (Test-Path $screenshotPath) {
|
||||
Write-Ok "Gespeichert: tmp\$filename"
|
||||
Write-Step "Screenshot: $filename"
|
||||
& $ADB $flags exec-out screencap -p > $screenshotPath
|
||||
if ((Test-Path $screenshotPath) -and (Get-Item $screenshotPath).Length -gt 0) {
|
||||
$sizeKB = [math]::Round((Get-Item $screenshotPath).Length / 1KB)
|
||||
Write-Ok "Gespeichert: tmp\$filename (${sizeKB} KB)"
|
||||
}
|
||||
else {
|
||||
Write-Err "Screenshot fehlgeschlagen"
|
||||
|
|
|
|||
17
.github/skills/android-emulator/SKILL.md
vendored
17
.github/skills/android-emulator/SKILL.md
vendored
|
|
@ -53,7 +53,7 @@ Verwaltet den Android-Emulator für die Krisenvorrat-App. Das Standard-AVD simul
|
|||
|
||||
```powershell
|
||||
$env:ANDROID_HOME = "C:\Users\JensR\AppData\Local\Android\Sdk"
|
||||
Start-Process "$env:ANDROID_HOME\emulator\emulator.exe" -ArgumentList "-avd S24Ultra_API35 -gpu auto"
|
||||
Start-Process "$env:ANDROID_HOME\emulator\emulator.exe" -ArgumentList "-avd S24Ultra_API35 -gpu guest -no-snapshot-load"
|
||||
```
|
||||
|
||||
### Auf Boot warten
|
||||
|
|
@ -115,7 +115,7 @@ do {
|
|||
|
||||
Der PackageManager ist noch nicht bereit, obwohl `sys.boot_completed` bereits 1 ist.
|
||||
|
||||
**Lösung:** 5 Sekunden nach `boot_completed=1` warten, dann installieren. Das Skript macht dies automatisch.
|
||||
**Lösung:** 30 Sekunden nach `boot_completed=1` warten, dann installieren. Das Skript macht dies automatisch.
|
||||
|
||||
### 2. Emulator startet nicht (`HAXM` / Hypervisor-Fehler)
|
||||
|
||||
|
|
@ -125,7 +125,18 @@ WHPX nicht verfügbar → Hyper-V muss aktiviert sein
|
|||
|
||||
Auf Windows: Hyper-V muss in Windows Features aktiviert sein. Der Emulator nutzt WHPX (Windows Hypervisor Platform).
|
||||
|
||||
### 3. Emulator-Fenster reagiert nicht
|
||||
### 3. OpenGL Core Profile nicht unterstützt (GPU-Problem)
|
||||
|
||||
Diese Maschine (NVIDIA GeForce MX130 / Intel UHD 620) unterstützt kein OpenGL Core Profile.
|
||||
Mit `-gpu auto`, `-gpu host`, `-gpu swiftshader_indirect` oder `-gpu angle_indirect` startet der
|
||||
Emulator-Prozess, zeigt aber kein Fenster und bindet keine ADB-Ports.
|
||||
|
||||
**Symptom:** `qemu-system-x86_64` läuft, aber `adb devices` zeigt keinen Emulator.
|
||||
|
||||
**Lösung:** Immer `-gpu guest` verwenden (Software-Rendering im Gast-VM). Das `android-dev.ps1`-Skript
|
||||
setzt dies automatisch über `$GPU_MODE = "guest"`.
|
||||
|
||||
### 4. Emulator-Fenster reagiert nicht
|
||||
|
||||
```powershell
|
||||
# Hard-Kill und Neustart
|
||||
|
|
|
|||
Loading…
Reference in a new issue