ADB
The android Debug Bridge for Android Devices
🔌 CONFIGURACIÓN INICIAL
Section titled “🔌 CONFIGURACIÓN INICIAL”Habilitar Depuración USB
Section titled “Habilitar Depuración USB”- Ve a Ajustes → Acerca del teléfono
- Toca 7 veces sobre Número de compilación hasta que aparezca “Ya eres desarrollador”
- Ve a Ajustes → Sistema → Opciones de desarrollador
- Activa Depuración USB y Depuración inalámbrica (si está disponible)
Comandos Básicos
Section titled “Comandos Básicos”adb devices # Lista dispositivos conectadosadb devices -l # Lista con más detalles (modelo, producto)adb version # Versión de ADB instaladaadb start-server # Inicia el servidor ADBadb kill-server # Detiene el servidor ADBadb help # Muestra todos los comandos disponiblesConectar un Dispositivo Específico
Section titled “Conectar un Dispositivo Específico”adb -s <serial_number> <command> # Envía comando a dispositivo específicoadb -d <command> # Envía al único dispositivo USBadb -e <command> # Envía al único emuladorEjemplo: adb -s emulator-5554 install app.apk
🌐 CONEXIÓN POR WI-FI
Section titled “🌐 CONEXIÓN POR WI-FI”Método Estándar (Primera Vez)
Section titled “Método Estándar (Primera Vez)”# 1. Conectar por USB primeroadb tcpip 5555 # Habilita TCP/IP en puerto 5555
# 2. Desconectar USB y conectar por IPadb connect <ip_dispositivo>:5555 # Ejemplo: adb connect 192.168.1.100:5555
# 3. Desconectaradb disconnect <ip_dispositivo>:5555Wi-Fi 2.0 (Android 11+)
Section titled “Wi-Fi 2.0 (Android 11+)”# 1. En dispositivo: Ajustes → Opciones desarrollador → Depuración inalámbrica# 2. Seleccionar "Emparejar con código de emparejamiento"# 3. Anotar IP, puerto y códigoadb pair <ip>:<puerto> # Ejemplo: adb pair 192.168.1.100:39939# Introducir el código cuando se solicite# El dispositivo se conectará automáticamente cuando esté en la misma red📦 GESTIÓN DE APLICACIONES
Section titled “📦 GESTIÓN DE APLICACIONES”Instalación
Section titled “Instalación”adb install <ruta_apk> # Instalar APKadb install -r <ruta_apk> # Reinstalar (conserva datos)adb install -d <ruta_apk> # Permite downgradeadb install -t <ruta_apk> # Instalar APK de pruebaadb install --abi arm64-v8a <apk> # Instalar para arquitectura específicaDesinstalación
Section titled “Desinstalación”adb uninstall <package_name> # Desinstalar appadb uninstall -k <package_name> # Desinstalar pero conservar datos/cachéadb shell pm uninstall <package> # Desde shelladb shell pm uninstall -k --user 0 <package> # Deshabilitar app de sistema (sin root)Listar Paquetes
Section titled “Listar Paquetes”adb shell pm list packages # Todos los paquetesadb shell pm list packages -3 # Solo apps de tercerosadb shell pm list packages -s # Solo apps de sistemaadb shell pm list packages | grep <nombre> # Buscar paquete específicoadb shell pm path <package> # Ruta del APK en el dispositivoLimpiar Datos
Section titled “Limpiar Datos”adb shell pm clear <package> # Borra datos y caché de la appadb shell am force-stop <package> # Forzar detención de la app📂 OPERACIONES CON ARCHIVOS
Section titled “📂 OPERACIONES CON ARCHIVOS”Transferir Archivos
Section titled “Transferir Archivos”adb push <local> <remoto> # Copiar archivo al dispositivoadb push -p <local> <remoto> # Copiar con barra de progresoadb pull <remoto> <local> # Copiar archivo desde el dispositivoadb pull /sdcard/DCIM/ ./fotos/ # Copiar carpeta completaComandos de Shell para Archivos
Section titled “Comandos de Shell para Archivos”adb shell ls /sdcard/ # Listar archivosadb shell mkdir /sdcard/nueva_carpeta # Crear directorioadb shell rm /sdcard/archivo.txt # Eliminar archivoadb shell rm -r /sdcard/carpeta # Eliminar directorioadb shell mv /origen /destino # Mover/Renombraradb shell cp /origen /destino # Copiaradb shell find /sdcard -name "*.jpg" # Buscar archivosadb shell du -sh /sdcard/DCIM # Tamaño de carpeta🖥️ CAPTURAS DE PANTALLA Y GRABACIÓN
Section titled “🖥️ CAPTURAS DE PANTALLA Y GRABACIÓN”Capturas
Section titled “Capturas”# Capturar y guardar en el dispositivoadb shell screencap -p /sdcard/captura.png
# Capturar y descargar directamente al PC (más rápido)adb exec-out screencap -p > captura.png
# Descargar después de capturaradb shell screencap -p /sdcard/captura.png && adb pull /sdcard/captura.pngGrabación de Pantalla
Section titled “Grabación de Pantalla”adb shell screenrecord /sdcard/video.mp4 # Grabar hasta Ctrl+Cadb shell screenrecord --time-limit 30 /sdcard/v.mp4 # Límite de 30 segundosadb shell screenrecord --size 720x1280 /sdcard/v.mp4 # Resolución personalizadaadb shell screenrecord --bit-rate 4000000 /sdcard/v.mp4 # Calidad🎮 CONTROL DE PANTALLA Y ENTRADA
Section titled “🎮 CONTROL DE PANTALLA Y ENTRADA”Toques y Gestos
Section titled “Toques y Gestos”adb shell input tap <x> <y> # Tocar en coordenadas (ej: 500 1000)adb shell input swipe <x1> <y1> <x2> <y2> # Deslizaradb shell input swipe <x1> <y1> <x2> <y2> <duración_ms> # Deslizar con duraciónadb shell input text "texto" # Escribir texto (escapar espacios con \)Eventos de Teclas (Key Events)
Section titled “Eventos de Teclas (Key Events)”adb shell input keyevent 26 # Encender/Apagar pantallaadb shell input keyevent 3 # Botón Inicioadb shell input keyevent 4 # Botón Atrásadb shell input keyevent 24 # Subir volumenadb shell input keyevent 25 # Bajar volumenadb shell input keyevent 82 # Menúadb shell input keyevent 187 # Aplicaciones recientesadb shell input keyevent KEYCODE_CAMERA # También se puede usar el nombre📊 INFORMACIÓN DEL DISPOSITIVO
Section titled “📊 INFORMACIÓN DEL DISPOSITIVO”Propiedades del Sistema
Section titled “Propiedades del Sistema”adb shell getprop # Todas las propiedadesadb shell getprop ro.product.model # Modelo del dispositivoadb shell getprop ro.build.version.release # Versión de Androidadb shell getprop ro.build.version.sdk # Nivel de APIadb shell getprop ro.serialno # Número de serieadb shell getprop ro.product.cpu.abi # Arquitectura del procesadoradb shell getprop persist.sys.locale # Idioma/configuración regionalPantalla y Resolución
Section titled “Pantalla y Resolución”adb shell wm size # Resolución actualadb shell wm density # Densidad de píxeles (DPI)adb shell wm size 1080x1920 # Cambiar resolución (requiere reinicio)adb shell wm size reset # Restaurar resolución originaladb shell wm density 420 # Cambiar DPIadb shell wm density reset # Restaurar DPIMemoria y Almacenamiento
Section titled “Memoria y Almacenamiento”adb shell cat /proc/meminfo | head -5 # Información de RAMadb shell df -h /data # Espacio de almacenamientoadb shell dumpsys meminfo <package> # Uso de memoria de una appadb shell top -n 1 | head -20 # Procesos principalesadb shell ps -A | grep <nombre> # Buscar proceso🔋 BATERÍA
Section titled “🔋 BATERÍA”adb shell dumpsys battery # Estado completo de la bateríaadb shell dumpsys battery set level <n> # Simular nivel (0-100)adb shell dumpsys battery set status <n> # 1=desconocido, 2=cargando, 3=descargando, 4=no cargando, 5=completoadb shell dumpsys battery set ac 1 # Simular cargador AC conectadoadb shell dumpsys battery set ac 0 # Simular cargador desconectadoadb shell dumpsys battery set usb 1 # Simular USB conectadoadb shell dumpsys battery reset # Restaurar estado real de la batería🔍 LOGS Y DEPURACIÓN
Section titled “🔍 LOGS Y DEPURACIÓN”Logcat
Section titled “Logcat”adb logcat # Mostrar logs en tiempo realadb logcat -c # Limpiar logsadb logcat -d > logs.txt # Guardar logs a archivoadb logcat *:E # Solo errores (E=Error, W=Warning, I=Info, D=Debug, V=Verbose)adb logcat -s <tag> # Filtrar por tagadb logcat --pid=<pid> # Logs de un proceso específicoadb logcat -G 16M # Aumentar tamaño del bufferDumpsys (Información Detallada)
Section titled “Dumpsys (Información Detallada)”adb shell dumpsys # Todo el estado del sistemaadb shell dumpsys activity # Estado del Activity Manageradb shell dumpsys activity activities | grep mResumedActivity # Actividad en primer planoadb shell dumpsys package <package> # Información detallada de un paqueteadb shell dumpsys wifi # Información de Wi-Fiadb shell dumpsys battery # Información de batería
# Informe completo de erroresadb bugreport # Genera informe completo (puede tardar)🔧 CONFIGURACIÓN DEL SISTEMA
Section titled “🔧 CONFIGURACIÓN DEL SISTEMA”Settings (Ajustes)
Section titled “Settings (Ajustes)”# Ver/Modificar ajustes del sistemaadb shell settings list system # Listar ajustes del sistemaadb shell settings list global # Listar ajustes globalesadb shell settings list secure # Listar ajustes seguros
# Obtener un valoradb shell settings get system <clave>
# Cambiar un valoradb shell settings put system <clave> <valor>Ejemplos Útiles
Section titled “Ejemplos Útiles”adb shell settings put system screen_brightness 128 # Brillo (0-255)adb shell settings put system screen_brightness_mode 0 # Brillo manual (0) / automático (1)adb shell settings put global airplane_mode_on 1 # Modo avión ONadb shell settings put global wifi_on 0 # Desactivar Wi-Fiadb shell settings put system font_scale 0.85 # Tamaño de fuenteadb shell settings put global development_settings_enabled 1 # Activar opciones desarrolladoradb shell settings put secure location_mode 3 # Alta precisión GPS🌐 RED Y CONECTIVIDAD
Section titled “🌐 RED Y CONECTIVIDAD”Wi-Fi, Datos, Bluetooth
Section titled “Wi-Fi, Datos, Bluetooth”adb shell svc wifi enable # Activar Wi-Fiadb shell svc wifi disable # Desactivar Wi-Fiadb shell svc data enable # Activar datos móvilesadb shell svc data disable # Desactivar datos móvilesadb shell svc bluetooth enable # Activar Bluetoothadb shell svc bluetooth disable # Desactivar Bluetoothadb shell cmd connectivity airplane-mode enable # Modo avión ONadb shell cmd connectivity airplane-mode disable # Modo avión OFFRedirección de Puertos
Section titled “Redirección de Puertos”adb forward tcp:<local> tcp:<remoto> # Reenviar puerto del host al dispositivoadb forward tcp:8080 tcp:8080 # Ejemplo: acceder a servicio local en dispositivoadb reverse tcp:<remoto> tcp:<local> # Reenviar puerto del dispositivo al host🚀 COMANDOS AVANZADOS
Section titled “🚀 COMANDOS AVANZADOS”Activity Manager (am)
Section titled “Activity Manager (am)”adb shell am start -n <package>/<activity> # Iniciar actividad específicaadb shell am start -a android.intent.action.VIEW -d <url> # Abrir URLadb shell am start com.android.settings # Abrir Settings (actividad principal)adb shell am start -n com.android.settings/.Settings$WifiSettings2Activity # Abrir Wi-Fiadb shell am force-stop <package> # Forzar detenciónadb shell am kill <package> # Matar proceso en segundo planoadb shell am broadcast -a <intent> # Enviar broadcastPackage Manager (pm)
Section titled “Package Manager (pm)”adb shell pm list permissions -g -r # Listar permisosadb shell pm grant <package> <permiso> # Conceder permisoadb shell pm revoke <package> <permiso> # Revocar permisoadb shell pm disable-user <package> # Deshabilitar app de usuarioadb shell pm enable <package> # Habilitar appadb shell cmd package install-existing <package> # Rehabilitar app de sistema deshabilitada🔑 ROOT Y COMANDOS AVANZADOS
Section titled “🔑 ROOT Y COMANDOS AVANZADOS”⚠️ Requieren dispositivo rooteado o bootloader desbloqueado
adb root # Reiniciar adbd con permisos rootadb remount # Remontar sistema como escriturableadb shell su # Cambiar a superusuario (desde shell)adb shell reboot # Reiniciar dispositivoadb reboot recovery # Reiniciar en modo recoveryadb reboot bootloader # Reiniciar en modo bootloader (fastboot)adb reboot edl # Reiniciar en modo EDL (Qualcomm)🔄 FASTBOOT (Bootloader)
Section titled “🔄 FASTBOOT (Bootloader)”# Primero reiniciar en bootloaderadb reboot bootloader
# Comandos fastbootfastboot devices # Listar dispositivos en fastbootfastboot oem unlock # Desbloquear bootloader (borra datos)fastboot flashing unlock # Método más nuevofastboot flash recovery twrp.img # Flashear recoveryfastboot flash boot boot.img # Flashear bootfastboot boot twrp.img # Arrancar temporalmente (sin flashear)fastboot erase userdata # Borrar datos de usuariofastboot erase cache # Borrar cachéfastboot reboot # Reiniciarfastboot reboot recovery # Reiniciar a recoveryfastboot getvar all # Mostrar todas las variablesfastboot getvar current-slot # Mostrar slot A/B activo🧰 COMANDOS ÚTILES ADICIONALES
Section titled “🧰 COMANDOS ÚTILES ADICIONALES”One-Liners Útiles
Section titled “One-Liners Útiles”# Extraer APK de un paquete instaladoadb pull $(adb shell pm path <package> | cut -d: -f2) ./app.apk
# Listar todas las apps con nombresadb shell pm list packages -f | sed "s/.*=//" | sort
# Buscar archivos grandes en /sdcardadb shell find /sdcard -size +100M -exec ls -lh {} \;
# Obtener la actividad en primer planoadb shell "dumpsys activity activities | grep mResumedActivity | cut -d ' ' -f 8"
# Ver logs filtrados por una app específicaadb logcat --pid=$(adb shell pidof -s <package>)Emulador
Section titled “Emulador”adb emu geo fix <longitud> <latitud> # Cambiar ubicación GPS (emulador)adb emu kill # Apagar emulador📚 REFERENCIA RÁPIDA DE KEYEVENTS
Section titled “📚 REFERENCIA RÁPIDA DE KEYEVENTS”| Código | Tecla | Código | Tecla |
|---|---|---|---|
| 3 | Home | 4 | Back |
| 26 | Power | 24 | Volumen + |
| 25 | Volumen - | 82 | Menú |
| 187 | Recientes | 66 | Enter |
| 67 | Delete | 111 | Escape |
| 122 | Move home | 123 | Move end |
| 20 | Tecla hacia arriba | 21 | Tecla izquierda |
| 22 | Tecla derecha | 19 | Tecla arriba |
💡 PRO TIP: Guarda esta cheatsheet para referencia rápida:
# Crear archivo con este contenidonano ~/adb_cheatsheet.md