Ubuntu上使用ADB工具

一直用两台电脑工作,xp工作端,ubuntu一直就只是编译服务器,因为是从事MTK的android方案开发,所以每次flash down工作都要到xp端,但是xp端的流氓软件太多(大家都知道的),总占用adb的端口,所以就准备用ubuntu(14.04)作为平时的调试平台;


一、工具的安装和几条指令(忽略)

    1.安装只要输入下面3条命令就可以了
    sudo add-apt-repository ppa:nilarimogard/webupd8
    sudo apt-get update
    sudo apt-get install android-tools-adb

     2.服务启动停止指令

  adb start-server – 实际上它会启动一个 adb fork-server server
  adb kill-server – kill掉
  adb devices – 列出所有的设备

二、设置usb权限

连上设备开始使用了,输入adbdevices
OMG!

List of devices attached

???????????? no permissions

竟然没权限,因为非root身份没权限使用usb调试,需要sudo支持。sdk帮助文档,发现sdk已经提供了说明;
详见: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 theSYSFS{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/Hardy, edit the file to read: [注:ubuntu 7.10及以后版本]
    SUBSYSTEM=="usb", SYSFS{idVendor}=="0bb4", MODE="0666"

    For Dapper, edit the file to read:  [注:ubuntu 6.06及以前版本]
    SUBSYSTEM=="usb_device", SYSFS{idVendor}=="0bb4", MODE="0666"

  2. Now execute:
    chmod a+r /etc/udev/rules.d/51-android.rules
下面开工,先用lsusb指令看电脑所有usb连接设备的接口
  $ lsusb
      。。。。。
  Bus 001 Device 010: ID 0bb4:0c87 High Tech Computer Corp.
      。。。。。
列表中,Bus 001 Device 010: ID 0bb4:0c87 High Tech Computer Corp. 这就是我们需要加入的设备的usb使用端口,vid为0bb4,pid = 0c87

  
$sudo vim /etc/udev/rules.d/70-android.rules
加入以下内容:
  
SUBSYSTEM=="usb",ATTRS{idVendor}=="0bb4",ATTRS{idProduct}=="0c87",MODE="0666"
      其中的idvendor idProduct指的是USB的ID可以使用lsusb查询得到。

运行命令,重启udev:
   
$sudo chmod a+rx /etc/udev/rules.d/70-android.rules
   $sudo service udev restart

三、重新启动adb server

(很重要)拔掉usb重新连上再执行:
     $adb kill-server
     $adb start-server
     $adb devices

四、如果上述方法仍无法连接adb,最直接有效的方法是:
使用lsusb查找到devID,以16进制写入到本地电脑隐藏目录文件[/home/用户名/.android/adb_usb.ini]中
最后打开一个命令行执行./adb devices即可 
Modify adb_usb.ini in /root/.android/ (if not exist, create it),  add 0x17EF at the end of line.
./adb kill-server
sudo ./adb devices


Ok, finished!

总结:

指令集增加:lsusb


你可能感兴趣的:(Ubuntu环境)