Difference between revisions of "Android: ADB setup"

From Compulab Mediawiki
Jump to: navigation, search
 
(One intermediate revision by one other user not shown)
Line 21: Line 21:
 
To access Android device, type in on the host PC:
 
To access Android device, type in on the host PC:
 
<pre>
 
<pre>
user@android $ export ADBHOST=<Android-device-IP-address>
+
root@ubuntu $ export ADBHOST=<Android-device-IP-address>
user@android $ adb kill-server
+
root@ubuntu $ adb kill-server
user@android $ adb start-server
+
root@ubuntu $ adb start-server
user@android $ adb <arguments>
+
root@ubuntu $ adb <arguments>
 
</pre>
 
</pre>
  
Line 45: Line 45:
 
<pre>user@android $ setprop service.adb.tcp.port -1</pre>
 
<pre>user@android $ setprop service.adb.tcp.port -1</pre>
  
* In Android graphic user interface enable ''Settings->Developer options->USB debugging''.
+
* In Android graphic user interface enable '''Settings'''->'''Developer options'''->'''USB debugging'''.
 +
{{Note|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.
 
* Connect the PC workstation to the Android device OTG port with a USB cable.
 
:At this point running {{cmd|adb devices}} on the PC workstation should list your Android device among attached ones.
 
:At this point running {{cmd|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:
 
To access the Android device, type in on the PC workstation:
Line 53: Line 55:
 
user@android $ adb kill-server
 
user@android $ adb kill-server
 
user@android $ adb start-server
 
user@android $ adb start-server
user@android $ adb <argsuments>
+
user@android $ adb <arguments>
 
</pre>
 
</pre>
  

Latest revision as of 06:12, 6 April 2014

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