In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article shows you the Android development and debugging tool ADB commands and installation example analysis, the content is concise and easy to understand, absolutely can make your eyes bright, through the detailed introduction of this article, I hope you can get something.
A brief introduction to ADB
Abbreviation: ADB
English full name: Android Debug Brige
English full name: Android debug bridge
Purpose: a tool for communicating with Android devices
Second, install ADB
Adb is included in the Android SDK platform tools package. You can download this package using SDK Manager, which installs it under android_sdk/platform-tools/.
Or, if you need a separate Android SDK platform tool package, you can click here to download it.
III. Environmental variables
For different configurations under Windows, Mac and Linux, you can search Baidu or Google according to the corresponding platform. This article is limited to space.
4. Connect the real machine
1. Enable developer options
Press the version number 7 times continuously (Settings > about Mobile phone > version number)
2. Enable USB debugging
Developer options > USB debugging
3. Enable file transfer
Change USB charging mode to file transfer
4. RSA key authorization for mobile phone
A dialog box pops up in the device, which must be manually determined to execute USB debugging and other adb commands
5. Check the ADB version with common commands
Adb version
Help information (important)
Adb-help
Or
Adb help
Or
Adb
The help information of ADB is very comprehensive. Learn to view the help information of command-line tools and get twice the result with half the effort.
Open the ADB server
Adb start-server
Close the ADB server
Adb kill-server
Check the equipment connection
Brief information: adb devices
Details: adb devices-l
Install App
General installation: adb install xxx.apk
Reinstall, keep data intact (overwrite installation): adb install-r xxx.apk
Allow debug package installation: adb install-t xxx.apk
Authorize runtime permissions for AndroidManifest.xml files and install: adb install-g xxx.apk
Push multiple apk to the device and install as one package: adb install-multiple xxx1.apk xxx2.apk
Uninstall App
Normal uninstall: adb uninstall com.xxx.package_name
Keep data unloaded: adb uninstall-k com.xxx.package_name
Push file
Push from the machine to the Android device: adb push local remote
Local represents the path to the native file
Remote represents the path of the Android device
Pull file
Pull from the Android device to the native: adb pull remote local
Remote represents the path to the file or directory of the Android device
Local represents the path to a native file or directory
View the log
Adb logcat
Advanced skills. Specify 1 or n of multiple Devic
The adb devices command or adb devices-l gets the serial numbers of all devices
1. Adb-s serial number command. For example: adb-s dasdfew123 install xxx.apk
Or
1. ANDROID_SERIAL environment variable, which can specify the serial number of a single device.
2. ANDROID_SERIAL environment variable, which can specify the serial numbers of n devices with a comma "," as the delimiter
When the serial number is not specified with-s, adb reads the value of the ANDROID_SERIAL environment variable
Using both the-s and ANDROID_SERIAL environment variables,-s overrides the value of the ANDROID_SERIAL environment variable
WLAN connection
Premise: the phone and PC are on the same local area network (under the same WLAN)
Principle: the adb server on PC establishes a TCP connection with the adbd process on the Android device
How do I establish a connection?
1. First connect the phone to PC through USB
Adb tcpip 5555
After running, the adbd process on the Android device will start listening on port 5555 (in the Listener state)
2. Unplug the phone from the USB connection
Adb connect
After running, the adb server on PC establishes a TCP connection with the adbd process on the Android device (listening on port 5555)
How do I disconnect the WLAN?
Adb disconnect
How do I switch a WLAN connection to a USB connection for an Android device?
Adb usb
Bluetooth connection
...... For the time being
Port forwarding
…… For the time being
Advanced Unix command line tools (Android is based on the Linux kernel) to view the commands available to Android devices (important)
Adb shell ls / system/bin
Enter the device shell
Adb shell
Execute any available command
(all commands listed in adb shell ls / system/bin can be used)
Top
Ps
Dumpsys
Am
Input
Wait, wait, wait... All kinds of orders. to be continued
8. Frequently used Unix command line tools
View process status: ps
View cpu status: top
System service: dumpsys
9. The principle of ADB adopts client / server architecture (Cramp S architecture), which consists of three processes
1. ADB client process
Run on PC, used to send commands, for the CLI client, start on the command line, the command runs to an end, and the process ends
2. ADB server process
It runs on PC and is started by the ADB client. It is responsible for communicating with the adbd process on the Android device and the ADB client process on the PC. The ADB client on the PC communicates with the adbd process on the Android device and is forwarded by the ADB server process on the PC.
3. Adbd process
Runs on Android devices and is responsible for communicating with ADB server processes on PC
Process communication mode
1. ADB client and ADB server
Both the ADB client and the ADB server run on PC and use TCP to establish a connection, namely Network Socket.
2. ADB server on PC and adbd process on Android device
Use USB cable to establish a connection (default)
Or
Using TCP to establish a connection (wireless adb)
Process life cycle
1. The life cycle of the ADB client process
Entering any adb command on the command line will create an ADB client process. When the client command execution ends, the adb client process will be destroyed naturally.
2. The life cycle of the ADB server process
Called by any client (such as adb command line, Android Studio, etc.), resident in PC memory as a daemon
3. The life cycle of the adbd process
The init process reads the init.rc file (which contains the configuration information of the adbd process), and then fork out the adbd process. The adbd process is created immediately after the Android system is started. It has been running in the memory of the Android as a daemon for the Android device.
5037 port
1. When starting any ADB client (Android Studio, command line tools, etc.), the ADB client checks whether the ADB server process is running
2. If the ADB server is not running, the ADB client executes the code that starts an ADB server process
3. After the ADB server starts, it will bind on the local port 5037 of PC (TCP port) to listen for commands issued by all ADB clients. All ADB clients communicate with ADB servers through TCP port 5037.
The above is the sample analysis of the ADB command and installation of the Android development and debugging tool. Have you learned the knowledge or skills? If you want to learn more skills or enrich your knowledge reserve, you are welcome to follow the industry information channel.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.