Small knowledge, big challenge! This paper is participating in theEssentials for programmers”Creative activities.

This paper has participated inProject DigginTo win the creative gift package and challenge the creative incentive money.

preface

With the development of science and technology, big and small things in our life are accompanied by the use of system (OS). From our 24-hour mobile phone 📱, the current mobile phone system is mainly divided into Android and IOS system. Among them, The Android system is the most common. It is not only used in mobile phones, but also in TV sets, smart speakers and other home products.

Android is an open source operating system based on Linux. It was created by Andy Rubin in California and acquired by Google in 2005. As of 2020, the Android version has been updated to Android11

For Android development team, in addition to understanding the Android system architecture, we also need to use the Debug tool ADB provided by Android to Debug and check.

In this installment, we will learn the basic usage of the Android debugging tool ADB, Let’s go~

The adb overview

ADB Debug Bridge is an Android command line tool used to connect emulators or actual Android devices to query and Debug related commands.

ADB:

ADB is a client-server program that is divided into three parts

  • Adb client: Window on the PC that sends ADB commands
  • Adb Daemond side (daemon) : run commands on the device, server process plus ADBD
  • Adb Server: This service is a daemon on the PC side that communicates between clients and postscripts

🌟 : The default communication port on the PC server is 5037, and the default background program port on the device is 5555

ADB features:

  • Manage device ports online
  • Remotely execute terminal commands
  • Files can be transferred between the PC and the device

The adb install

Windows installation:

  1. Go to the official website to download the adb
  2. Place it in a specific directory such as c:\adb
  3. Go to the environment and add the adB. exe folder to the PATCH variable

  1. Open CMD terminal, enter ADB, you can view the want to have ADB command print instructions

MAC System installation:

  1. Brew install android-platform-tools

  2. Configuring environment Variables

    (1) On the terminal, go to the home directory

    (2) Open the.bash_profile file, open. Bash_profile

    (3) Add at the end of the.bash_profile file

     ```
     export ANDROID_HOME=/Users/yourname/Library/Android/sdk
     export PATH=$PATH:$ANDROID_HOME/tools
     export PATH=$PATH:$ANDROID_HOME/platform-tools
     ```
    Copy the code

3.source .bash_profile

  1. Verify that ADB was installed successfully

Adb common commands

Adb common commands role
adb devices View all connected devices
adb connect IP Connect to the device through the DEVICE IP address
adb install PATH Install the application on the device
adb uninstall PATH Write in the uninstallation application
adb pull DPATH PPath Download the specified file from the device to the PC
adb push PcPath DPath Uploads specified files from the computer to the device
adb logcat Print log
adb shell In the shell environment of the device, you can run Linux commands
adb root Grant the root permission to the device
adb disconnect The PC disconnects adb from the device
adb kill-server Stop the adb server

Adb shell common commands

The adb shell command role
adb shell dumpsys package View details about the specified application package
adb shell am start [options] Starts the specified application event
adb shell input text Enter text through the input command
Adb shell getProp < property > View a single system property
adb shell cat /proc/meminfo Command to view memory information
adb shell cat /proc/cpuinfo Command to view CPU information
adb shell netcfg/ifconfig View the IP address of the device
adb shell ps Check the process
adb shell top View the real-time resource usage
adb shell monkey -p < packagename > Perform the Monkey stress test
adb shell shell screencap Obtain device screen shots
adb shell dumpsys [options] Viewing System Information

conclusion

In this installment, we will learn about the components, installation, and common commands of ADB, a debugging tool commonly used on Android devices.

In daily work, we can use ADB tools efficiently when we need to debug and test Android devices

Above the content of this issue, welcome big guy point praise comment, we see next period ♥️ ~