In the process of development or testing, we can manage multiple devices through the ADB in the general format of:
adb [-e |-D |-s < device serial number;] < sub-command >
With the environment variables in place, enter ADB help in the command window or enter ADB directly, and all the option descriptions and subcommands will be listed.
Here are some of the commands that are commonly used:
12 [xuxu:~]$ adb devices34 44c826a0 device
1 adb kill-server, end adb service 2 adb start-Server, start adb service 34
General in connection exception,5 use ADB devices not properly listed device,6 device state is abnormal when using kill-server, 7 then run Start-server to restart the service
1 adb logcat, print the Android system log
1 adb bugreport, 2 3
4 adb bugreport > D:\bugreport.log
1 adb install, installation application, overwrite installation is use-r option 2 windows if you need to install APK with Chinese name, ADB needs to be modified
12'-k' means keep the data and the cache directories,-K option, Save data and cache directory when uninstalling
1 adb pull to copy files or folders on your Android device to local 2 For example, copy sdcard files under Pull.txt to D-drive: 3 adb pull Sdcard/pull.txt D: 4 If you need to rename to Rename.txt: adb pull Sdcard/pull.txt d:\rename.txt 6 Note permissions, copy files under directory of system permissions, require root, 7 and generic Android root cannot be copied using commands, 8 9 First mount the system's file system as writable, 10 to copy Mobile system files on your phone
1 adb push, push local files to Android device 2 3 adb push d:\push.txt sdcard/4sdcard The trailing slash cannot be less, otherwise the following error will occur:5 [xuxu:~ ]$ adb push push.txt sdcard6'push.txt'sdcard ' : is a directory 7 permissions issues with pull command
1 adb reboot, restart Android device
1 bootloader, restart device, enter FastBoot mode, with ADB reboot-bootloader command
1 Recovery, restart the device, enter the recovery mode, often brush the students more familiar with this mode
12 adb forward TCP:1314 tcp:8888313148888 Port,4 so you can control your Android device remotely.
1 adb connect remote connect Android device 2 3192.168. 1.102 , you can connect the phone wirelessly, the disadvantage is that the speed is relatively slow
1 adb shell pm2 package Manager, which can be used to get some application information installed on Android devices3 4 pm Source Pm.java, directly run adb shell PM can get help information to this command5 PM List package lists the apps installed on the device6 without any options: List all the app's package names (don't know how to find the app's package name for the classmates to see here)7 adb shell pm List Package8-s: List system applications9ADB shell PM List Package-sTen-3: List third-party apps OneADB shell PM List Package-3 A-F: List the app package name and the corresponding APK name and storage location -ADB shell PM List Package-F --I: List the app package name and its installation source the - pm Install, installing the app - The target apk is stored on the PC side, please install it with ADB installation - target apk is stored on Android device, please install it with PM install + pm Uninstall, uninstall the application, with ADB uninstall, followed by the parameters are the package name of the app - pm Clear, erase app data +PmSet-install-location, PMGet-install-Location , setting app installation locations, getting app installation locations A[0/Auto ]: default is Auto at[1/Internal]: Default is installed inside the phone -[2/external]: Default installation on external storage
1 adb shell am2 am Start, start an Activity3 Start the camera4ADB shell am start-n com.android.camera/. Camera5 the camera stops first and then starts6ADB shell am start-s com.android.camera/. Camera7 wait for the camera to finish booting8ADB shell am start-w com.android.camera/. Camera9 start a default browser to open a Web pageTenADB shell am start-a android.intent.action.view-d http://www.google.com OneStart Dialer Call10086 AADB shell AM START-A android.intent.action.call-d Tel:10086 - monitoring crash and ANR -ADB Shell AM Monitor
1 adb shell input2 send key events to an Android device3 Send text content, cannot send Chinese4 adb shell input text test1234565 Send key event, simulate press Home button6 adb shell input keyevent keycode_home7To send a touch event to the screen, click on the screen coordinates to - -the location8ADB shell input Tap - -9 swipe events, swipe the screen from right to leftTenADB shell input Swipe the - - - One 4. Long press action above version 4 AADB shell input Swipe - - 501 501 -
1 adb shell screencap 2 Command 3 screenshot, save to SDcard directory 4 adb shell screencap-p/sdcard/screen.png
1 adb shell Screenrecord 2 4.4 New Recording Commands 3 start recording, record results saved to SDcard 4 adb shell Screenrecord sdcard/record.mp45 Execute command after operation phone, CTRL + C end Recording
1 adb shell uiautomator 2 Gets control information for the current interface 3 Span style= "COLOR: #000000" > Gets control information, which is stored by default under SDcard 4 adb Shell uiautomator dump 5 plus [file] option, you can change position
1 adb shell IME 2 Input Method 3 list input methods on a device 4 adb shell IME List-5 Select Input Method 6set com.baidu.input_mi/. Imeservice
ADB shell WM get device resolution ADB shell WM size
Finally, there's a command group called
Android Monkey
Android Common ADB commands