Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to usb-connect android devices with adb under ubuntu [closed]

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

like image 840
stefan bachert Avatar asked Feb 19 '12 15:02

stefan bachert


People also ask

Can I Enable USB debugging using adb?

Enable adb debugging on your device To use adb with a device connected over USB, you must enable USB debugging in the device system settings, under Developer options. To use adb with a device connected over Wi-Fi, see Connect to a device over Wi-Fi.

How do I enable adb remotely?

Type adb tcpip 5555 in the command line or Terminal and press Enter. Find your phone's IP address in Settings > About Phone > Status > IP Address. Back in the command line or Terminal, type adb connect [your Android's IP address]. Finally, press Enter again.


2 Answers

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."

like image 56
Alex P. Avatar answered Sep 20 '22 19:09

Alex P.


use following three command its works for me

sudo bash
adb kill-server
adb usb
like image 24
Tanvir Dalal Avatar answered Sep 22 '22 19:09

Tanvir Dalal