---
name: android_app_uninstall
kind: function
lang: bash
domain: infra
version: "1.0.0"
purity: impure
signature: "android_app_uninstall([--serial <S>] package [--keep-data]) -> void"
description: "Uninstall app via adb uninstall. Optionally keep data with --keep-data."
tags: [android, adb, app, uninstall, pendiente-usar]
params:
  - name: "--serial <S>"
    desc: "Optional target device/emulator serial. Auto-detects first connected device if omitted."
  - name: "package"
    desc: "Android package name to uninstall (e.g. com.example.myapp). Mandatory positional argument."
  - name: "--keep-data"
    desc: "Keep app data + cache after uninstall (passes -k to pm uninstall)."
output: "Stdout 'uninstalled <pkg> on <serial>'. Exit 0 OK."
uses_functions: [adb_wsl_bash_infra]
uses_types: []
returns: []
returns_optional: false
error_type: "error_go_core"
imports: []
tested: false
tests: []
test_file_path: ""
file_path: "bash/functions/infra/android_app_uninstall.sh"
---

## Ejemplo

```bash
# Desinstalar en el device por defecto
android_app_uninstall com.example.myapp

# Desinstalar en un device concreto
android_app_uninstall --serial emulator-5554 com.example.myapp

# Desinstalar conservando datos y cache
android_app_uninstall --serial emulator-5554 com.example.myapp --keep-data
```

## Notas

Sourcea `adb_wsl.sh` para resolver el binario `adb.exe` en WSL2 y usar
`adb_pick_serial` / `adb_s`. Si no hay ningún device conectado y no se
pasa `--serial`, la función falla con exit 1 antes de invocar adb.

El flag `--keep-data` pasa `-k` a `adb uninstall`, equivalente a
`pm uninstall -k` — el APK se elimina pero los datos y la caché de la app
permanecen en el dispositivo.
