How to usb-connect android devices with adb under ubuntu

33,393

Solution 1

The Google recommended way to deal with ADB device permissions is to create an UDEV rule which would set appropriate permissions on device enumeration.

As per http://developer.android.com/tools/device.html

If you're developing on Ubuntu Linux, you need to add a udev rules file that contains a USB configuration for each type of device you want to use for development. In the rules file, each device manufacturer is identified by a unique vendor ID, as specified by the ATTR{idVendor} property. For a list of vendor IDs, see USB Vendor IDs, below. To set up device detection on Ubuntu Linux: Log in as root and create this file: /etc/udev/rules.d/51-android.rules. Use this format to add each vendor to the file: SUBSYSTEM=="usb", ATTR{idVendor}=="0bb4", MODE="0666", GROUP="plugdev"

In this example, the vendor ID is for HTC. The MODE assignment specifies read/write permissions, and GROUP defines which Unix group owns the device node. Note: The rule syntax may vary slightly depending on your environment. Consult the udev documentation for your system as needed. For an overview of rule syntax, see this guide to writing udev rules. Now execute: chmod a+r /etc/udev/rules.d/51-android.rules When plugged in over USB, can verify that your device is connected by executing adb devices from your SDK platform-tools/ directory. If connected, you'll see the device name listed as a "device."

Solution 2

use following three command its works for me

sudo bash
adb kill-server
adb usb
Share:
33,393
stefan bachert
Author by

stefan bachert

Very senior freelancer system architect nearby Karlsruhe, Germany. Java, JEE, JSE, J2ME C/C++ Angular JS + Angular 2/4 abas ERP, abas EDP XML HTML5, CSS Material Design JDBC, SQL, MySQL, Postgres... and much more Fair contracts and project offers are welcome. [email protected] current interests: machine learning. (Coursera, Andrew Ng)

Updated on June 29, 2020

Comments

  • stefan bachert
    stefan bachert almost 4 years

    Other may have experienced problems with adb debugging under ubuntu linux.

    The symptom is the availability of usb connected android devices e.g. with eclipse. You may test this with

    adb usb
    

    When you get

    error: insufficient permissions for device
    

    you probably run into the same problem like me. However, I found on the internet some more or less sub optimal solutions

    The basic idea is to start adb as root. The solutions I found were cumbersome.

    One proposal is to start adb per sudo. An other proposal was to set up a boot script in /etc/init.d

    My solution is to give adb the permission to start as root. To do so, switch to root

    sudo bash
    chown root adb
    chmod ug+s-w adb
    

    security fanatics may propose

    sudo chown root adb
    sudo chmod ug+s-w adb
    

    If adb is already running you need to kill the demon to start with root permission

    adb kill-server
    

    When everything went right

    adb usb
    

    should return

    restarting in USB mode
    

    if not, try lsusb th check whether your device is already connected

  • Chris Stratton
    Chris Stratton over 9 years
    -1 Do not run adb as root