Android ADB common commands and environment configuration

write picture description here

It is difficult for us to use the ADB debugging bridge for debugging in Android. Now I will collect some ADB commands that we use every day. Of course, there are special plug-ins in AndroidStudio that can be downloaded and used for us, but I still like to use commands. Because it will be a bit more constraining.

ADB stands for Android Debug Bridge, Android Debug Bridge. ADB works in a special way. The IDE communicates with Qemu by listening to the Socket TCP port. By default, adb will daemon-related network ports. Proficiency in using ADB commands will greatly improve development efficiency. There are many ADB commands. Today, I will summarize some ADB commands that I commonly use in TV development.

Configure the ADB environment

1. Configure ADB
write picture description here

2. Then add it to the system path
write picture description here

Common commands are as follows

Display all devices in the system: adb devices
Terminate the adb service process: adb kill-server
Restart the adb service process: adb start-server
Check the screen resolution: adb shell wm size
Install the apk to the sd card: adb install -s // For example: adb install -s baidu.apk
install APK: adb install //for example: adb install baidu.apk
uninstall APK: adb uninstall //for example: adb uninstall com.baidu.aaa
uninstall app but keep data and cache files: adb uninstall -k / /For example: adb uninstall -k com.baidu.search

Connect device: adb connect 192.168.1.61
Disconnect device: adb disconnect 192.168.1.61

List the package names of all apps installed on the phone: adb shell pm list packages
List all package names of system applications: adb shell pm list packages -s
List third-party application package names except system applications: adb shell pm list packages - 3

Reboot to recovery, the recovery mode: adb reboot recovery

View the log: adb logcat
Clear the log cache: adb logcat -c
View the bug report: adb bugreport

Get the MAC address of the machine: adb shell cat /sys/class/net/wlan0/address
Get the CPU serial number: adb shell cat /proc/cpuinfo

Retain data and cache files and reinstall apk: adb install -r //For example: adb install -r baidu.apk
to clear application data and cache: adb shell pm clear (apk package name)

Start the application: adb shell am start -n /.
Force stop the application: adb shell am force-stop (apk package name)
Delete the system application:
adb remount (remount the system partition to make the system partition rewritable).
adb shell
cd system/app/
ls
rm *.apk

Check the CPU and memory usage of the device: adb shell top
Check the top 6 apps occupying memory: adb shell top -m 6
Refresh the memory information once, and then return: adb shell top -n 1
Check the memory usage of each process: adb shell procrank

Kill a process: adb shell kill [pid]
adb shell
ps
kill pid
ps is the command to view the process, kill pid the process you want to kill

View the process list: adb shell ps
View the status of the specified process: adb shell ps -x [PID]
View background services information: adb shell service list
View the current memory usage: adb shell cat /proc/meminfo
View the IO memory partition: adb shell cat / proc/iomem remounts
the system partition as a read-write partition: adb remount
Copy files from local to device: adb push
Copy files from device to local: adb pull

List the files and folders in the directory, which is equivalent to the dir command in dos: adb shell ls
enters the folder, which is equivalent to the cd command in dos: adb shell cd

Rename the file: adb shell rename path/oldfilename path/newfilename
Delete system/avi.apk: adb shell rm /system/avi.apk
Delete the folder and all files below it: adb shell rm -r

Move files: adb shell mv path/file newpath/file
Set file permissions: adb shell chmod 777 /system/fonts/DroidSansFallback.ttf

Create a new folder: adb shell mkdir path/foldelname
View file content: adb shell cat
View wifi password: adb shell cat /data/misc/wifi/*.conf

Get device name: adb shell cat /system/build.prop
View ADB help: adb help
Run monkey: adb shell monkey -v -p your.package.name 500

Related Libraries

If you need to see more information about ADB, please see Github related libraries to learn about
https://github.com/mzlogin/awesome-adb

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325566032&siteId=291194637