More articles:
1、 Basic operation
Install app
adb install -r xxx. Apk // overwrite the installation and keep the data and cache files
adb install -s xxx. Apk // install APK to SD card
adb install -f xxx. Apk // install APK into internal system memory
adb install -d xxx. Apk // install lower version apk
adb install -g xxx. Apk // allow all permissions in APK manifest
Get installation location
adb shell pm get-install-location
Uninstall app
adb uninstall <package>
ADB uninstall -k <package> // uninstall the app but keep the data and cache files
Restart the phone
adb reboot
Start ADB service
adb start-server
Shut down service
adb kill-server
Enter shell environment
adb shell
2、 View device information
View the connected device and its corresponding serial number
adb devices
Check the phone CPU architecture (eg.armv7) and the number of cores
adb shell cat /proc/cpuinfo
View the detailed memory information of the system, including the kernel
adb shell cat /proc/meminfo
Get phone disk space
adb shell df
Get mobile system version
adb shell getprop ro.build.version.release
Get the MAC address of the machine:
adb shell cat /sys/class/net/wlan0/address
View WiFi password
adb shell cat /data/misc/wifi/*.conf
3、 PM / am related
Clear applied data
adb shell pm clear <package>
View app path
adb shell pm path <package>
View package names for all installed apps
adb shell pm list packages -f
View the package name of the app with the “Google” field
adb shell pm list packages google
View package names of third-party apps
adb shell pm list packages -3
Start an activity of an application
adb shell am start -n packagename/packagename.activityname
For example: ADB shell am start -n com company. appname/ . SplashActivity -es url http://www.baidu.com
//-Es indicates the parameter to be passed, where URL indicates the parameter name and link indicates the specific parameter value
Make a call
adb shell am start -a android.intent.action.CALL -d tel:10086
Open web site
adb shell am start -a android.intent.action.VIEW -d http://www.baidu.com
4、 Process / service view
View process information
adb shell ps | grep xxx
View specified process status
adb shell ps -x [pid]
Periodically print out the process running queue, system switching, CPU time ratio, etc
adb shell vmstat
Memory usage of each process
adb shell procrank
Kill a process
adb shell kill [pid]
View background services information
adb shell service list
5、 Dumpsys series
View the dump service supported by the current mobile phone
adb shell dumpsys -l
Viewing package informationpackage information
adb shell dumpsys package
ADB shell dumpsys package packages | grep <package> // view an app resource path
View memory usage
adb shell dumpsys meminfo | grep xxx
ADB shell dumpsys meminfo <pid> // output the memory usage of the specified PID
ADB shell dumpsys meminfo --package <package> // output the memory usage of the specified package name
ADB shell top -m 6 // view the top 6 apps in memory
View the activity at the top of the stack, which can be used to obtain the package name and view the package name of other apps
adb shell dumpsys activity top
View rendering time
adb shell dumpsys gfxinfo <package> > /sdcard/fps.txt
Fetch file: ADB pull /sdcard/fps txt /Users/admin/Downloads/1234. txt
View am status
adb shell dumpsys activity
Memory Use Over Time
adb shell dumpsys procstats
6、 File operation
Move files / folders
adb shell mv path/file newpath/file
New folder
adb shell mkdir path
new file
adb shell touch filename
Rename file / folder
adb shell rename path/filename newpath/newfilename
view file contents
adb shell cat file
Copy files from your phone to your PC
adb pull /data/anr/traces.txt /Users/admin/Downloads/1234.txt
Send files from your computer to your phone
adb push foo.txt /sdcard/foo.txt
7、 Log correlation
view log
adb logcat | grep xxx
Log output to file
adb logcat -d > ~/Desktop/logcat. Txt // saving to the desktop requires android permission. READ_ LOGS
Clear log cache
adb logcat -c
8、 Other
Connect to the specified IP, usually with WiFi debug
adb connect <device-ip-address>
Run monkey
ADB shell monkey -v -p <package> 500 // run 500 times
Screenshot
adb shell /system/bin/screencap -p /sdcard/screenshot.png
adb pull /sdcard/screenshot. png ./ Dowload/screenshot. Png (save to PC)
Adobe Captivate
adb shell screenrecord --time-limit 30 /sdcard/demo.mp4
adb pull /sdcard/demo.mp4 ./Downloads/
In depth learning