Android: ADB setup

From Compulab Mediawiki
Revision as of 06:12, 6 April 2014 by Nadav (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Overview

Android Debug Bridge (adb) is a versatile command line tool that lets you communicate with connected Android-powered device or an emulator instance.
To name a few of its features:

  • command line shell
  • installed package management
  • IDE interface for application development
  • Android device available access options are:
    • Over network (IP)
    • Over USB link

Please refer to Android developer network for more details.

Getting ADB

In general ADB is provided within the Android SDK. Also some Linux disributions provide the ADB within their package repositories. For example, on Ubuntu platform, ADB may be obtained via android-tools-adb package.

ADB over IP

ADB over IP may be configured by executing the following command line on the Android device:

user@android $ setprop service.adb.tcp.port 5555

To access Android device, type in on the host PC:

root@ubuntu $ export ADBHOST=<Android-device-IP-address>
root@ubuntu $ adb kill-server
root@ubuntu $ adb start-server
root@ubuntu $ adb <arguments>

Among useful arguments are

  • devices - list connected Android devices
  • shell - run command line shell
  • logcat - view Android log
  • install - install Android application (*.apk)
  • push - copy file from host to Android device

ADB over USB

  • Properly configure a Linux PC workstation, e.g. on Ubuntu this should be:
root@ubuntu $ echo SUBSYSTEM==\"usb\", ATTR{idVendor}==\"18d1\", MODE=\"0666\", GROUP=\"plugdev\" >> /etc/udev/rules.d/51-android.rules
  • ADB over USB requires ADB over IP be disabled.
Test ADB TCP port by executing on Android device:
user@android $ getprop service.adb.tcp.port
If there is a value, and it is not -1 - it should be set to -1:
user@android $ setprop service.adb.tcp.port -1
  • In Android graphic user interface enable Settings->Developer options->USB debugging.
Admolition note.png If Developer options item is hidden (as is the default in Jelly Bean and newer), re-introduce it proceeding to Settings->About tablet and clicking on Build number 7 times consequently.
  • Connect the PC workstation to the Android device OTG port with a USB cable.
At this point running adb devices on the PC workstation should list your Android device among attached ones.
  • In newer Android releases, a dialog might pop up on the Android device, requesting the user to confirm connection to a particular PC.

To access the Android device, type in on the PC workstation:

user@android $ adb kill-server
user@android $ adb start-server
user@android $ adb <arguments>

See Also