ADB-android debug Bridge)

Source: Internet
Author: User

ADB, short for Android debug bridge, is a tool in the android SDK. It can be used to directly manage Android simulators or real Android devices (such as G1 mobile phones ).

Its main functions include:

Run the shell of the device (command line)
Manage port ing between simulators and devices
Upload/download files between computers and devices
Install the local APK software on a simulator or Android device

ADB is a client-server program, where the client is the computer you use to operate and the server is an Android device.

First, let's talk about the installation method. You need to install the client on your computer. The client is included in the SDK. You do not need to install it on the device. You just need to open the option settings-applications-Development-USB debugging on your mobile phone.

For Mac and Linux users, after the downloaded SDK is decompressed, you can ~ Or any directory. Then modify ~ /. Bash_profile file, set the runtime environment to point to the SDK's tools directory. Specifically, open ~ /. Bash_profile file (if this file is not available, you can add it yourself), add a line in it:

Export path =$ {path }:< your SDK directory>/tools

For example:

Then you can use the ADB command.

You can skip the installation steps and enter the full path to use the command.

Now let's talk about several commands commonly used by ADB.
1. View Devices

ADB Devices
This command is used to view the currently connected devices. The Android devices or simulators connected to the computer are listed and displayed.

2. Install software

ADB install <APK file path>
This command installs the specified APK file on the device.

ADB-S can specify the serial number of the simulator to select which one to manipulate. For example, ADB-s emulator-5554 install email.apk indicates that email.apk is installed on emulator-5554.

3. uninstall software

ADB uninstall <software Name>
ADB uninstall-k <software Name> note that the package name is used, for example, Com. Zhang. Android. helloworld.

If the-k parameter is added, the software is uninstalled but the configuration and cache files are retained.

You can upload and install the application APK package from the development environment to the actual hardware device or android simulator, execute the above "ADB install" command, followed by the APK file path name. Run the "ADB Uninstall" command, followed by the package name, to remove the application APK package. Note that the installation is based on the APK file path name (ADB install helloworld.apk), while the removal is based on the package name (ADB uninstall com. example. Android. helloworld ). The detailed package name can be found in the "/data/Data" directory of the Android operating system or the "/data/APP" Directory (you must run the "ADB shell" command to enter the Android operating system)

 

4. log on to the device Shell

ADB Shell
ADB shell <command>
This command will log on to the shell of the device. after entering the command line mode of the Android operating system, you can use the CTRL + D or "exit" command to exit the console window.

The <command> command is used to directly run the device command, which is equivalent to executing the remote command.

5. transfer files between devices and computers

ADB push <local path> <remote path> use the push command to copy files or folders on the local computer to the device (mobile phone)

ADB pull <remote path> <local path> run the pull command to copy files or folders on the device (mobile phone) to the local computer.

The "ADB push" command can upload files to the SD memory card directory "/sdcard", because the Android operating system will protect system files and other directories will have access permissions and cannot be written freely, therefore, most user files or photo files are stored in the "/sdcard" directory. The "ADB pull" command operates in the opposite direction. It downloads files from the "/sdcard" directory of the Android operating system to a PC. Another common practice is to extract the application APK package from the "/data/Data" directory or the "/data/APP" directory, provide developed applications for other users.

6. display help information

ADB help
This command displays help information

7.

$ ADB logcat (Monitor simulator Operation Records)
ADB logcat monitors the records generated during the running of the android simulator in real time. This function can be used by program developers for debugging. developers can obtain error messages generated when the application is running from the record. After running ADB logcat, to exit monitoring mode, press Ctrl + C.

8.

$ ADB bugreport (generate ADB debugging Report)
To learn more about all error message reports generated by the system, you can run the ADB bugreport command to display the dumpsys, dumpstate, and logcat information of the Android system.

9.
$ ADB get-State (to obtain the operational status of the ADB server) ADB get-state will show the operational status of the ADB server, there are offline (offline), bootloader (starting) and device (in operation.

10.
$ ADB start-server (starts the ADB server) $ ADB kill-server (disables the ADB server) usually starts the ADB server when the android server is started. You can use ADB get-

State to check the status of ADB. If it is not started, run ADB start-server to start it. If you do not want to perform debugging monitoring, run ADB kill-server to disable it.

ADB command parameter table

Usage instructions
 
Parameters
ADB-d
When the Android phone is connected to the computer by USB,

You can run commands on the device through ADB-D.
 
ADB-e
Commands for running Simulators
 
ADB-S
Specify the serial number of the simulator
 
General Purpose
ADB Devices
Display the number of the currently started simulator device
 
ADB help
Display ADB command usage
 
ADB version
Show ADB version
 
Information Processing
ADB install
Install the APK Application Component
 
ADB push
Upload a file or directory
 
ADB pull
Download files or directories
 
Command Column
ADB Shell
Enter the command column mode of the android System
 
Debugging
ADB logcat
Monitor simulator Operation Records
 
ADB bugreport
Generate ADB debugging report
 
Server
ADB start-Server
Start the ADB Server
 
ADB kill-Server
Disable the ADB Server
 
ADB get-state
Obtains the operational status of the ADB server.
 
ADB get-serialno
Obtain the simulator running number
 
Network
ADB forward TCP: Port
Change the network TCP communication port of the simulator

ADB install-s xxx.apk installer to SD card

ADB install-r xxx.apk reinstall Program

ADB uninstall-K xxx.apk save data and cache path

The following error occurs when running Eclipse:

Emulator: Error: cocould not create temporary hardware. ini: Permission denied

Solution: first run the simulator and emulator, then run the program under eclipse, and select the corresponding simulator or device.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.