Yuri Muhin's CV
To make sure the device you are going to manipulate with is actually connected use: adb devices
Returns the list of created emulators on your machine (their names): emulator -list-avds
Start the emulator: -avd <emulator_name>
Killing the adb server “In some cases, you might need to terminate the adb server process and then restart it
to resolve the problem (e.g., if adb does not respond to a command).
To stop the adb server, use: adb kill-server
Some other useful commands
Returns the list of the devices properties; could be useful when you need to get, say, a device model or Android version
adb shell getprop
Returns Android version installed one the device (for example Android 8.0 ) adb shell getprop ro.build.version.release
Returns API level (for example 27): adb shell getprop ro.build.version.sdk
Reboots the device: adb reboot
Inspect battery diagnostics: adb shell dumpsys batterystats options
The output typically includes the following:
*History of battery-related events
*Global statistics for the device
*Approximate power use per UID and system component
*Per-app mobile milliseconds per packet
*System UID aggregated statistics
*App UID aggregated statistics
Monkey tool
“The Monkey is a program that runs on your emulator or device and generates pseudo-random streams of user events such as clicks, touches, or gestures, as well as a number of system-level events.”
Sends 500 random clicks and touches to Dabbl application: adb shell monkey -p com.adjoy.standalone -v 500
Change battery level
adb -e shell dumpsys battery set level 15 for virtual device
adb -e shell dumpsys battery reset for virtual device
adb -d shell dumpsys battery set level 15 for real (physical) device
adb -d shell dumpsys battery reset for real (physical) device
Install, Update, Uninstall an application
Install to Device: adb install Downloads/Dabbl-v1.45-adjoyAlpha.apk
Update to Device: adb install -r Downloads/Dabbl-v1.45-adjoyAlpha.apk
Uninstall from Device: adb uninstall com.adjoy.standalone.test2 - use package name
Clears all package data from the device; after running this command, the is if it were just installed
adb shell pm clear com.adjoy.standalone.test2
Find package name
Returns all packages installed on the device: adb -d shell pm list packages
Returns all installed by user. Returns third party packages that were installed from Play store or as .apk (not pre-installed): adb -d shell pm list packages -3
Returns the package for the specific application: adb -d shell pm list packages -f yours_app_name
Video record the screen
Video record the screen: adb shell screenrecord /sdcard/phone_number.mp4
To stop recording (or stop any action) press: ctrl+ c
Copy recording to your DEVICE: adb pull /sdcard/phone_number.mp4
Default recording time is 180 seconds (3 minutes). You may, however, change the that by adding following the arguments.
adb shell screenrecord --time-limit 120/sdcard/phone_number.mp4
instead of 120 AND placeholder, insert the needed time in seconds: --time-limit 120 will produce a 2-minute video.
Take a screenshot
Take a screenshot: adb shell screencap /sdcard/phone_number.png
Copy screenshot to your DEVICE: adb pull /sdcard/phone_number.png
To remove a file from your device
To remove your file from your device, run: adb shell rm /sdcard/phone_number.mp4
Connecting a physical device via WiFi
Steps:
1. Your phone and computer are ON THE SAME WiFi
2. Connect your Android phone via USB
3. adb devices type in your promtp (command) line
4. adb tcpip 5555 type in your promtp (command) line
6. Disconnect device from USB
6. adb connect 192.168.0.100:5555
Where the first part before <:> is your phone ip : the last part after <:> is your port_number_for_server (usually 5555).
7. adb disconnect - disconnects every physical device connected this way
How to find ip from command line adb -d shell ip addr show wlan0
How to find your device ip? View phone IP from Settings > About Phone > Status
Collecting application logs
Collect logs in prompt line. The command to start logging: adb logcat
Clears all the info that might be in buffer from the previous sessions: adb logcat -c OR ctrl+c
FOR PC searches for exact string of the app: adb logcat | findstr "adjoy" means adb logcat | findstr " your app`s name"
In the first part ADB looks for EXACT STRING OF OUR APP adb logcat | findstr "adjoy" > zip_code_crash.txt IN THE LAST PART WE CREATE txt file (log file)
FOR PC creates log (txt) file with command (promt) line: adb logcat > file_name.txt
Note: On Windows machine, please use find (or findstr) instead of grep - for ex., find “adjoy”
FOR iOS: adb logcat | grep 'adjoy' > zip_code_crash.txt
Note: I f you need to grep more than one word, please do the following: adb logcat | grep -E "(adjoy|dabbl)"
Prints the output in the console and also saves to a file: adb logcat | tee logfile.txt
Logcat sources: https://developer.android.com/studio/command-line/logcat