Use adb command
1 Introduction
Android Debug Bridge we generally referred to as the adb, mainly located in the platform-tools installation directory files in sdk folder, it is a very powerful command-line tool, you can interact with your android device through this tool.
adb's environment to build self-Baidu, environment building is relatively simple, the general use adb to be carried out in the developer debug mode, before connecting, first open the debug mode.
2.adb commonly used commands
View adb version 2.1
Command: adb version
2.2 Connecting simulator
Command: adb connect 127.0.0.1:62001
Description: adb connec simulator connected after the IP address and port number, then you do not need a real machine so connected
2.3 adb shell
android underlying device is a Linux system, shell is the character interface Linux system, usually the system adb command operations, most of them are about to enter adb shell state to operate.
After entering the adb shell display has two states: # representatives have root privileges; $ representatives without root privileges
After the root, the user privilege level is high, easy to misuse, it is generally a lot of mobile phone manufacturers do not allow the user root
2.4 with adb command to install the device on the APK
The default installation : adb install APK path on the PC side of
Drag may be directly APK cmd command directly to the window, the path that will automatically add the APK
Covering installation: already has an older version of the APK on your machine, you want to install the new version of the APK can be used to cover the installation, then you need to add a -r command later install in the back
Command: adb install -r APK path on the PC side of
2.5 Uninstall APK
1) into the first device data / app directory
2) execute the command to delete
Format: adb unistall apk's package name
2.6 View application installed on the device package name
命令:adb shell pm list package
2.7 reads and writes files
1) to write files from PC to device
adb pull <location of the file on the PC side> <path into device>
* Note that the intermediate between two paths separated by a space, the path is no parentheses
2) the files into the device from the PC
adb pull <introduced into the device path> <PC side file location>
** Note that due to permission issues, files can not be imported directly into the computer disk root directory
2.8 Screenshots
Command: Save the adb shell screencap image path (this path is the path prototype end)
If you want pictures on the PC side images can be imported into the PC
Example: The following is a theme and theme introduced into the end of the PC operation, may be packaged into a file bat, bat file can run directly screenshot
@echo
adb shell uiautomator dump /sdcard/app.uix
adb pull /sdcard/app.uix F:\uix\app.uix
adb shell screencap -p /sdcard/app.png
adb pull /sdcard/app.png F:\uix\app.png
pause
* Pause is to prevent flew close cmd window run the command
summary:
1.adb is a very important tool for automation
2. At present, many PC clients connect adb Mobile Assistant is also based on the principle of the package.
3. adb command may be encapsulated into common commands bat, ready to run.