Add driver configuration for ADB in Linux

Source: Internet
Author: User

Recently, due to the large number of built-in partners, many Android mobile phones of many manufacturers in my Ubuntu system cannot be correctly identified. After some hard work, I checked the SDK, now we have sorted out the ADB driver configuration methods in Linux and solutions to the problems encountered in them and contributed them to you.

In Linux, you can connect to ADB in Mobile USB debugging mode for Android program debugging. The configuration driver is not intuitive in windows.

Procedure

First confirm that the mobile phone is connected to the computer, lsusb to view the device records.

Matthew@Matthew-1230-laptop :~ $ Lsusb
Bus 007 device 009: Id 18d1: 4e12
Bus 007 device 001: Id 1d6b: 0002 Linux Foundation 2.0 root Hub
Bus 006 device 001: Id 1d6b: 0001 Linux Foundation 1.1 root Hub
Bus 005 device 001: Id 1d6b: 0001 Linux Foundation 1.1 root Hub
Bus 003 device 001: Id 1d6b: 0002 Linux Foundation 2.0 root Hub
Bus 002 device 001: Id 1d6b: 0001 Linux Foundation 1.1 root Hub
Bus 001 device 001: Id 1d6b: 0001 Linux Foundation 1.1 root Hub
Bus 004 device 004: Id 093a: 2510 pixart imaging, Inc.
Bus 004 device 001: Id 1d6b: 0001 Linux Foundation 1.1 root Hub

Here I am:

Bus 007 device 009: Id 18d1: 4e12

Create a configuration file 51-android.rules under/etc/udev/rules. d /.

Sudovim/Etc/Udev/Rules. d/50-android.rules

Add the following configuration parameters to the file:

Subsystem = "USB", sysfs{"High Tech Computer Corp ."}= "0bb4", mode = "0666"

Save, Set permissions for the configuration file

SudochmodA + RX/Etc/Udev/Rules. d/50-android.rules

Restart

Sudo/Etc/Init. d/Udev restart

Then restart the ADB service. (If NO environment variable is configured, go to the android SDK tools directory and run sudo./ADB kill-server./ADB devices)

SudoADB kill-Server
SudoADB Devices

Supplement

Sysfs parameters:

Sysfs{"Idvendor"}= "XXX"

The sysfs parameter in the Linux ADB driver configuration file refers to the device vendor. Because it was a mobile phone made by HTC for Google, "High Tech Computer Corp." was first written on the official website .". But now, a group of mobile phone manufacturers, such as Moto, Sony Ericsson, and Samsung, have joined more than HTC. What should I do if the device model is not 0bb4?

When reading the SDK help documentation, I found that the SDK has provided instructions:
(For details, see Docs/GUIDE/developing/device.html)

If you're developing on Ubuntu Linux, you need to add a rules file that contains a USB configuration for each type of device you want to use for development. each device manufacturer uses a different vendor ID. the example rules files below
Show how to add an entry for a single vendor ID (the HTC vendor ID ). in order to support more devices, you will need additional lines of the same format that provide a different value for the sysfs {idvendor} property. for other IDs, see the Table of USB
Vendor IDs, below.

1. log in as root and create this file:/etc/udev/rules. d/51-android.rules.

For gusty/hard, edit the file to read: [Note: Ubuntu 7.10 and later versions]
Subsystem = "USB", sysfs {idvendor} = "0bb4", mode = "0666 ″

For dapper, edit the file to read: [Note: Ubuntu 6.06 and earlier versions]
Subsystem = "usb_device", sysfs {idvendor} = "0bb4", mode = "0666 ″
2. Now execute:
Chmod A + R/etc/udev/rules. d/51-android.rules

Follow the instructions to change 0bb4 in the 51-android.rules file to the corresponding USB vendor ID.
For example, my mobile phone is Motorola and idvender is 22b8.
So this line is

Subsystem = "USB", sysfs{Idvendor}= "22b8", mode = "0666"

However, you can write multiple lines to use various devices. For example, I wrote all the following:

# ACS 0502
Subsystem = "USB", sysfs{Idvendor}= "0502", mode = "0666"
# Dell 413c
Subsystem = "USB", sysfs{Idvendor}= "413c", mode = "0666"
# Foxconn 0489
Subsystem = "USB", sysfs{Idvendor}= "0489", mode = "0666"
# Garmin-Asus 091e
Subsystem = "USB", sysfs{Idvendor}= "091e", mode = "0666"
# HTC 0bb4
Subsystem = "USB", sysfs{Idvendor}= "0bb4", mode = "0666"
# Huawei 12d1
Subsystem = "USB", sysfs{Idvendor}= "12d1", mode = "0666"
# Kyocera 0482
Subsystem = "USB", sysfs{Idvendor}= "0482", mode = "0666"
# LG 1004
Subsystem = "USB", sysfs{Idvendor}= "1004", mode = "0666"
# Motorola 22b8
Subsystem = "USB", sysfs{Idvendor}= "22b8", mode = "0666"
# NVIDIA 0955
Subsystem = "USB", sysfs{Idvendor}= "0955", mode = "0666"
# Pantech 10a9
Subsystem = "USB", sysfs{Idvendor}= "10a9", mode = "0666"
# Samsung 04e8
Subsystem = "USB", sysfs{Idvendor}= "04e8", mode = "0666"
# Sharp 04dd
Subsystem = "USB", sysfs{Idvendor}= "04dd", mode = "0666"
# Sony Ericsson 0fce
Subsystem = "USB", sysfs{Idvendor}= "0fce", mode = "0666"
# ZTE 19d2
Subsystem = "USB", sysfs{Idvendor}= "19d2", mode = "0666"

However, the above IDs cannot include all of them. The usb id of a device is not listed above.
You can use the lsusb command to view your usb id.

Matthew@Matthew-1230-laptop :~ $ Lsusb
Bus 002 device 003: Id 413c: 2003 Dell Computer Corp. keyboard
Bus 002 device 002: Id 0461: 4d22 primax electronics, Ltd
Bus 002 device 001: Id 1d6b: 0001 Linux Foundation 1.1 root Hub
Bus 001 device 010: Id 18a1: 0002
Bus 001 device 001: Id 1d6b: 0002 Linux Foundation 2.0 root Hub

Find the above ID as 18a1 and add the device to the file.

Subsystem = "USB", sysfs{Idvendor}= "18a1", mode = "0666"

Modify/etc/udev/rules. d/51-android.rules. You do not need to restart the Linux machine and re-plug the device. Run ADB devices again to see that your device is connected.

Matthew@Matthew-1230-laptop:/OPT/Android/Android-sdk-linux_86/Tools $Sudo./ADB
Devices
List of devices attached
0403502001011000 Device

Before that, you may see

Matthew@Matthew-1230-laptop:/OPT/Android/Android-sdk-linux_86/Tools $Sudo./ADB
Devices
List of devices attached
???????????? No Permissions

 

A little bit

 

1. Download ADB for Linux first

Web: http://developer.android.com/sdk

My version is:
Linux (i386) android-sdk-linux_x86-1.5_r3.zip

2. decompress:
-------------
$ Unzip android-sdk-linux_x86-1.5_r3.zip
-------------

3. Rename:
-------------
$ Android-sdk-linux_x86-1.5_r3 ADB mv
-------------

2. Configure environment variables:
-------------------
$ Gedit ~ /. Bashrc
-------------------
Add

----------------------------
# Android path
Export Path = $ path: $ home/ADB/tools
----------------------------

Note:
Is added after the text,
$ Home refers to the user directory.
ADB is the development package path just renamed.

3. Create a USB driver File
Enter the hypervisor to add the device file (in the window, it can be understood as a driver)
-------------------
$ Su-
# Gedit/etc/udev/rules. d/51-android.rules
-------------------

Add the following code
--------------------
Subsystem = "USB", sysfs {idvendor} = "0bb4", mode = "0666"
--------------------

4. Restart your computer
-------------
# Reboot
-------------
5. Restart the test command,
Connect to the USB cable.
If # is displayed, OK is displayed.
If err appears,
There are only two situations,
First, USB is not properly connected,
Second, the device file is written incorrectly.

-------------------
$ ADB Shell
* Daemon not running. Starting it now *
* Daemon started successfully *
#

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.