adb shell entry

A, the ADB Introduction
ADB (Android Debug Bridge) is Android Developer / tester irreplaceable general command line tool, which allows communication with the emulator or instances connected Android device. It provides convenient operations for a variety of devices, such as installation and debugging applications, and provides access to the Unix shell (in the simulator can be used to run or connect various devices command). Android system is based on the Linux kernel, so Linux in many commands in Android also has the same or similar implement, you can call in adb shell inside. The tool is a client - server program.

Client: Client running on the development computer. You can command from the command line by issuing an adb client terminal calls.

Daemon: daemon runs on each emulator or device instance as a background process.

Server: Server runs as a background process on the development computer.

Second, the installation : adb downloading unzip to a custom path, configuration environment variable.

Third, the connection :
the ADB bind the local TCP port 5037, and listens for commands from the client sends adb (adb all clients use port 5037 to communicate with the server adb).
1. Connect the Android emulator
night God emulator: adb Connect 127.0.0.1:62001
2.USB connection Android device
. A developer options open
Settings> About phone> Number The continuous click Build
. B turn on USB debugging
enter adb under c .Dos devices to verify that the phone connected to the adb
3. mobile phones and computers connected to the same LAN adb connect ip 

Fourth, frequently used commands

1, install the application
(1) adb install D: \ adbtest \ baidu.apk file names without spaces

(2) adb push D: \  adbtest \ baidu.apk / system / app
 will be the corresponding original system apk overwritten 
available adb pull /system/app/baidu.apk / home / backup

Sometimes Read-only error occurs, we can use force install command to install APK
adb install -r D: \ adbtest \ baidu.apk

2, unloading
adb uninstall com.baidu.browser.apps

3, import / export file to your phone
adb pull Remote local
adb the Push local Remote

4, the package management commands PM
adb shell PM List Packages Standard Package -3 to view third-party installation package
according to the package name to view the apk installation path
adb shell pm path com.baidu.browser.apps package name
Clear app data
adb shell pm clear com.baidu. browser.apps package name

5, dumpsys inquiry service system dump to the screen:
View all Activity
adb shell dumpsys Activity Activities,
obtaining Activity currently running
adb shell dumpsys activity | findstr Run

6, view the system processes
adb shell Top
adb shell PS
Ps provide only a snapshot of the current process. top instantly view the most active process 

7, fetch log logcat the adb
the adb logcat -v Time *: E> D: \ and outputs the test.log fetch log path to develop
adb logcat ActivityManager: i *: s  
view the activity log, only the outputs labeled "ActivityManager" and greater than or equal priority "Info" log, *: S for setting a priority of all the log mark is S, this ensures that only the output of the logs match condition.
Only the display output (white list) required, via pipes grep filtered.
References (https://www.cnblogs.com/bydzhangxiaowei/p/8168598.html)

8, adb shell monkey Stress Test
Resources (https://www.cnblogs.com/yindada/p/9845032.html)
the adb the shell Monkey com.baidu.browser.apps -v -p 1000> D: \ adbtest \ monkey_test .txt
-p, this command is used to specify the package, without specifying the execution throughout the system
-v, for verbosity level feedback log
level 0: adb shell monkey -p package name -v 10 // default level, only a small amount of information is started, the test is completed and the final results, etc.   

Level 1: adb shell monkey -p package name -v -v 10 // provide more detailed logs, including event information is sent to each of Activity

Level 2: adb shell monkey -p package name -v -v -v 10 // provide the most detailed logs, including the test checked / unchecked Activity Information
1. unresponsive: ANR problem: search in the log " ANR "
2. crash: Search log" cRASH "
3. other issues: search the log" Exception "

9, the user operates the simulated
click events
adb shell input keyevent <keycode> 
sliding
adb shell input swipe 300 1000 300 500
text input
adb shell input text hello, world

10, screen shots, video:
adb shell screencap /system/test.png file path
adb shell screenrecord file path

When Android adb debugging often encounter permission problems (failed for /system/lib/libmm-test.so, Read-only file system), even if the Root device, when the / system folder and other operating systems (such as push, rm, etc.), you may still be prompted to "Read-only file system". adb remount remount the system partition, the system partition or re-write the reboot (http://www.metsky.com/archives/670.html)

screenrecord some parameters
--size width x height set the resolution EG: 1280x720
--bit Rate Rate video bit-rate, the default value is 4Mbps, 6Mbps may be provided, so that better quality eg: adb shell screenrecord --bit-rate 6000000 / System / demo.mp4
--time time-limit setting the maximum recording length (in seconds). The default and maximum values are 180 (3 minutes)

References https://github.com/mzlogin/awesome-adb

Released seven original articles · won praise 6 · views 645

Guess you like

Origin blog.csdn.net/weixin_36273267/article/details/103766610