Android Debug Bridge: Difference between revisions

From Android Wiki
(Created by translating the page "Android Debug Bridge")
Tag: contenttranslation
 
No edit summary
 
(One intermediate revision by the same user not shown)
Line 1: Line 1:
{{DISPLAYTITLE:Android Debug Bridge (ADB)}}
The '''A'''ndroid-'''D'''ebug-'''B'''ridge (abbreviated as ''adb'') is a software-interface for the [[android]] system, which can be used to connect an android device with a computer using an USB cable or a wireless connection. It can be used to execute commands on the phone or transfer data between the device and the computer.<ref>[http://developer.android.com/guide/developing/tools/adb.html Dokumentation zu ADB (englisch)]</ref>
The '''A'''ndroid-'''D'''ebug-'''B'''ridge (abbreviated as ''adb'') is a software-interface for the [[android]] system, which can be used to connect an android device with a computer using an USB cable or a wireless connection. It can be used to execute commands on the phone or transfer data between the device and the computer.<ref>[http://developer.android.com/guide/developing/tools/adb.html Dokumentation zu ADB (englisch)]</ref>


Line 55: Line 56:


If you now open a new command line window at any directory on your computer, you should get a list of adb commands when you just type:<pre>adb</pre>
If you now open a new command line window at any directory on your computer, you should get a list of adb commands when you just type:<pre>adb</pre>
=== Linux ===
=== Linux ===
On most big Linux distirbutions, there's an adb and fastboot package, e.g.:
On most big Linux distirbutions, there's an adb and fastboot package, e.g.:
Line 75: Line 72:
|}
|}
On other distributions you can look in your packet manager for a package named ''android'' or ''adb'' and install the corresponding one. If there's no package, you can download the separate platform-tools package (see the introduction section) and put it somewhere. If you also want to use adb (and maybe fastboot) from anywhere in your system, you can symlink the binaries to the /bin directory:
On other distributions you can look in your packet manager for a package named ''android'' or ''adb'' and install the corresponding one. If there's no package, you can download the separate platform-tools package (see the introduction section) and put it somewhere. If you also want to use adb (and maybe fastboot) from anywhere in your system, you can symlink the binaries to the /bin directory:
ln -s /path/to/android/platform-tools/adb /bin/adb


ln -s /path/to/android/platform-tools/fastboot /bin/fastboot
<code>ln -s /path/to/android/platform-tools/adb /bin/adb</code>
 
<code>ln -s /path/to/android/platform-tools/fastboot /bin/fastboot</code>


== See also ==
== See also ==

Latest revision as of 18:30, 4 August 2017

The Android-Debug-Bridge (abbreviated as adb) is a software-interface for the android system, which can be used to connect an android device with a computer using an USB cable or a wireless connection. It can be used to execute commands on the phone or transfer data between the device and the computer.[1]

The tool is part of the Android SDK (Android Software Development Kit) and is located in the subdirectory platform-tools. In previous versions of the SDK it was located in the subdirectory tools. Since January 2017, Google also provides the package in a separate, unbundled downloadable package with all other platform-tools, in which also the ADB and fastboot is included. The user now does not need to download the complete SDK just for the ADB and/or fastboot anymore.[2][3][4][5] The download link is provided on the Android-Developer website.

What is ADB?

The Android Debug Bridge is a software interface between the device and the local computer, which allows the direct communication of both components. This includes the possibility to transfer files from one component to the other one, as well as executing commands from the computer on the connected device. The ADB can be used through a command line windows, terminal/shell in Linux-based systems, a command line (cmd) for Windows. There's no official graphical user interface for now.

The main advantage is to execute commands on the phone directly out of the computer, without any direct user interaction to the phone, which makes especially debugging a lot easier.

Apart from the possibility to connect a phone for using ADB using the usb cable (which was, for a long time, the only possible way), there's also the possibility to connect to the ADB daemon on the device using a tcp connection, which also includes the WiFi network.

Important commands

In the following list you find some important commands, which you may need more often when working with the adb. If you want to view the help and a complete list of adb commands of the version you're using, just type the following command and hit return:

adb help

Show connected devices

Lists connected and available devices (only devices which have USB-Debugging enabled)

adb devices

If there's an output something like this:

List of devices attached

there're most likely no devices connected, or there're no USB drivers installed (correctly) Does the output look like:

List of devices attached
????????????	no permissions

you, if you're using Windows, most likely need to write the Vendor ID of the device manufacturer (which can be found in the device manager) into this file (the format is: 0xZZZZ, where Z is a hexadecimal number from 0 to F):

%USERPROFILE%\.android\adb_usb.ini

The important thing is, that the vendor ID is written as it's own line in this file. When using Linux, the file can be found in the home directory of the current user in the hidden directory .android. The Vendor ID can be found with the command lsusb.

Copy files

  • From the device to the computer:
    adb pull /pfad/am/handy.txt /pfad/am/computer.txt
  • From the computer to the device:
    adb push /pfad/am/computer.txt /pfad/am/handy.txt

Install applications

You can install apps on the device. However, this requires the APK file to be present on the local computer (the user also needs to be able to access this file):

adb install /pfad/zur/datei/anwendung.apk

Logcat

You can also show the system log using adb:

adb logcat

Sometimes it's useful to write (pipe) the output/the system log to a separate file (however, this is the default behavior of the system and not a special function of the ADB):

adb logcat > datei.txt

Open an interactive shell

To execute commands on the android device, you can use the following command. It will, if called without any arguments, open an interactive shell on the device, which is disaplayed in your console/terminal window. If you pass a string as an argument to the command, it will be executed on the device as a command for the device and the shell will be closed, once the command was executed.

adb shell

Installation

Installation and setting the adb as a system environment variable in Windows

To avoid the need to navigate to the directory where the adb is located in each time you want to use the adb, you can add the directory to the PATH environment variable of your WIndows sytsem. That allows you to use adb commands in a command line windows, no matter where on the system you currently are. If you're using Windows 7 (it's slightly different on future versions of Windows, but basically the same) you can follow these steps:

  1. Control Panel
  2. System and security
  3. System
  4. Advanced System settings
  5. Environment variables

Afterwards look for the Path variable in the System variables section and add the path to the platform-toolsdirectory on the system. The path needs to be absolute (not relative) and needs to be separated from the current value using a semicolon (;) (take a look to the image).

If you now open a new command line window at any directory on your computer, you should get a list of adb commands when you just type:

adb

Linux

On most big Linux distirbutions, there's an adb and fastboot package, e.g.:

Distribution Packagename
Ubuntu, Debian android-tools-adb
openSUSE, Fedora, Arch Linux android-tools
Slackware android-tools (as aSlackBuild)

On other distributions you can look in your packet manager for a package named android or adb and install the corresponding one. If there's no package, you can download the separate platform-tools package (see the introduction section) and put it somewhere. If you also want to use adb (and maybe fastboot) from anywhere in your system, you can symlink the binaries to the /bin directory:

ln -s /path/to/android/platform-tools/adb /bin/adb

ln -s /path/to/android/platform-tools/fastboot /bin/fastboot

See also

References