ADB Shell
Few handy commands you can use to interact with emulator/device, through terminal.
Description | Command |
---|---|
List all connected devices | adb 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 application | adb uninstall your.app.package |
Download a file from device | adb pull /sdcard/file.ext |
Upload a file to a device | adb push file.ext /sdcard |
Print all installed packages on device | adb shell pm list packages -f |
Clear Application data | adb shell pm clear your.app.package |
Toggle Data for device | adb shell svc data disable |
Toggle Wifi for device | adb 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 permissions | adb shell pm reset-permissions -p your.app.package |
Reset a specific permission | adb shell pm revoke your.app.package android.permission.WRITE_EXTERNAL_STORAGE |
Broadcast Actions | adb shell am broadcast -a 'my_action' |
Simulating Android killing your app in the background | adb shell am kill |
Take a Screenshot | adb shell screencap -p \| perl -pe 's/\x0D\x0A/\x0A/g' > screenshot.png |
Launch an installed app using its package name | adb 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 system | adb 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 logs | adb logcat |
To save Android device logs locally on your computer using ADB | adb logcat > device_logs.txt |