Skip to content

Instantly share code, notes, and snippets.

@emenjivar
Last active August 8, 2025 19:00
Show Gist options
  • Select an option

  • Save emenjivar/01651f497162eb453ee591015e9ace3e to your computer and use it in GitHub Desktop.

Select an option

Save emenjivar/01651f497162eb453ee591015e9ace3e to your computer and use it in GitHub Desktop.
ADB simple tricks

ADB tricks

Screen mirroring

# Mirror the screen
scrcpy

# View only
scrcpy --no-control

# Disables audio
scrcpy --no-audio 

# Disables video mirroring (audio only)
scrcpy --no-video 

# Record screen to file
scrcpy --record file.mp4 

App management

# Install an apk
adb install file.apk

# Install apk allowing downgrade
adb install -d file.apk

# Uninstall an apk
adb uninstall com.emenjivar.lonelinessdiary

# Get APK path
adb shell pm path com.emenjivar.lonelinessdiary

# Extract APK path
adb shell pm path com.emenjivar.lonelinessdiary | cut -d':' -f2 | xargs -I {} adb pull {}

Input simulation

# Send text input 
adb shell input text "Hello World" 

# Physical size 
adb shell wm size 

# Screen density (DPI)
adb shell wm density 

# Tap at coordinates 
adb shell input tap 500 1000 

# Swipe gesture 
adb shell input swipe 300 1000 300 500 

# Key events 
adb shell input keyevent KEYCODE_HOME 
adb shell input keyevent KEYCODE_BACK 
adb shell input keyevent KEYCODE_POWER

Screenshot and recording

# Take screenshot 
adb shell screencap /sdcard/screenshot.png 
adb pull /sdcard/screenshot.png 

# Record video (Android 4.4+) 
adb shell screenrecord /sdcard/demo.mp4 
adb pull /sdcard/demo.mp4

# Record a video with time limit
adb shell screenrecord --time-limit 10 /sdcard/demo.mp4
adb pull /sdcard/demo.mp4

Device exploration

# Start a unix terminal
adb shell

# Get android version
adb shell getprop ro.build.version.release 

# Device model
adb shell getprop ro.product.model

# Get manufacturer
adb shell getprop ro.product.manufacturer

App permissions

# Show granted permissions
adb shell dumpsys package com.emenjivar.lonelinessdiary | grep permission

# Grant permission
adb shell pm grant com.emenjivar.lonelinessdiary android.permission.READ_CONTACTS

# Revoke permissions
adb shell pm revoke com.emenjivar.lonelinessdiary android.permission.READ_CONTACTS

# Reset the permissions for an specific app
adb shell pm reset-permissions -p com.emenjivar.lonelinessdiary

# Warning: Reset the permissions for all the app
adb shell pm reset-permissions
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment