ADB Shell

Few handy commands you can use to interact with emulator/device, through terminal.

DescriptionCommand
List all connected devicesadb devices
Install an application on device
-s to install on the SD Card
-g to grant all permissions listed in the manifest [More Info]
adb install -r ~/application.apk
Uninstall an applicationadb uninstall your.app.package
Download a file from deviceadb pull /sdcard/file.ext
Upload a file to a deviceadb push file.ext /sdcard
Print all installed packages on deviceadb shell pm list packages -f
Clear Application dataadb shell pm clear your.app.package
Toggle Data for deviceadb shell svc data disable
Toggle Wifi for deviceadb shell svc wifi enable
Location of Device
- High accuracy: gps,wifi,network or gps,network (if you want the wifi)
- Battery saving: wifi,network or network only
- Device only: gps
adb shell settings put secure location_providers_allowed gps
Reset all granted permissionsadb shell pm reset-permissions -p your.app.package
Reset a specific permissionadb shell pm revoke your.app.package android.permission.WRITE_EXTERNAL_STORAGE
Broadcast Actionsadb shell am broadcast -a 'my_action'
Simulating Android killing your app in the backgroundadb shell am kill
Take a Screenshotadb shell screencap -p \| perl -pe 's/\x0D\x0A/\x0A/g' > screenshot.png
Launch an installed app using its package nameadb shell monkey -p com.yourapp.packagename 1
Stress test your app using its package name by sending a pseudo-random stream of user events into the systemadb shell monkey -p com.yourapp.packagename -v 500
Send input text to a connected device instead of typing manually.adb shell input text "[email protected]"
Check device logsadb logcat
To save Android device logs locally on your computer using ADBadb logcat > device_logs.txt