How to usb-connect android devices with adb under

2019-03-27 08:05发布

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

2条回答
Bombasti
2楼-- · 2019-03-27 08:23

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

查看更多
做个烂人
3楼-- · 2019-03-27 08:30

use following three command its works for me

sudo bash
adb kill-server
adb usb
查看更多
登录 后发表回答