Ubuntu12.04系统下使用小米2真机调试

手机利用USB连接到Ubuntu 12.04系统。运行下面的命令:

wujianjun@thinkpad:/media/DATA/Java-linux/android-sdk-linux/platform-tools$ lsusb

Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

Bus 003 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub

Bus 004 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 006 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub

Bus 007 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub

Bus 008 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub

Bus 002 Device 002: ID 17ef:4808 Lenovo

Bus 002 Device 003: ID 2717:9039

拔掉手机的USB连接线,再运行:


wujianjun@thinkpad:/media/DATA/Java-linux/android-sdk-linux/platform-tools$ lsusb

Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

Bus 003 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub

Bus 004 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 006 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub

Bus 007 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub

Bus 008 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub

Bus 002 Device 002: ID 17ef:4808 Lenovo



对比发现,Bus 002 Device 003: ID 2717:9039    就是小米手机的


sudo vi  /etc/udev/rules.d/50-android.rules在打开的文件中增加以下文本:

SUBSYSTEM=="usb", SYSFS{idVendor}=="2717", MODE=="0666"
SUBSYSTEM=="usb_device", SYSFS{idVendor}=="2717", MODE=="0666"
SUBSYSTEM=="usb", ATTR{idVendor}=="2717", ATTR{idProduct}=="9039", SYMLINK+="android_adb"


sudo chmod a+rx /etc/udev/rules.d/50-android.rules



注意,这个50-android.rules 文件名字应该是随意命名的,试过 51-android.rules ,52-android.rules  似乎是都可以的。

注意 "SUBSYSTEM=="usb", SYSFS{idVendor}=="2717", MODE=="0666" "这句是给 ubuntu 7.01 以后的系统识别用的

而"SUBSYSTEM=="usb_device", SYSFS{idVendor}=="2717", MODE=="0666""是给 Ubuntu 7.01之前的系统识别用的。相当于系统兼容。



wujianjun@thinkpad:/etc/udev/rules.d$ sudo service udev restart

udev stop/waiting

udev start/running, process 2968


在 android sdk 的 tools 目录下运行 (这一步很重要,必须要sudo,否则没效果)


wujianjun@thinkpad:/media/DATA/Java-linux/android-sdk-linux/platform-tools$ sudo ./adb kill-server

wujianjun@thinkpad:/media/DATA/Java-linux/android-sdk-linux/platform-tools$ sudo ./adb devices

* daemon not running. starting it now on port 5037 *

* daemon started successfully *

List of devices attached

到这一步了,结果发现 List of devices attached 下面没有设备出现,这就意味着 adb不识别新的USB 设备,纠结了。


如果跟我一样悲惨,请执行如下操作

wujianjun@thinkpad:~$ cd ~/.android/

wujianjun@thinkpad:~/.android$ ls
adbkey       adb_usb.ini~     avd       debug.keystore     repositories.cfg
adbkey.pub   androidtool.cfg  cache     default.keyset     sites-settings.cfg
adb_usb.ini  androidwin.cfg   ddms.cfg  modem-nv-ram-5554

请注意这个 adb_usb.ini

wujianjun@thinkpad:~/.android$ vi adb_usb.ini

里面的内容一般如下:

# ANDROID 3RD PARTY USB VENDOR ID LIST -- DO NOT EDIT.
# USE 'android update adb' TO GENERATE.
# 1 USB VENDOR ID PER LINE.


我们在其中加一行

# ANDROID 3RD PARTY USB VENDOR ID LIST -- DO NOT EDIT.
# USE 'android update adb' TO GENERATE.
# 1 USB VENDOR ID PER LINE.
0x2717


请注意,这个 0x2717 就是我们得到的设备号码


保存,关掉,然后

wujianjun@thinkpad:/media/DATA/Java-linux/android-sdk-linux/platform-tools$ sudo ./adb kill-server

wujianjun@thinkpad:/media/DATA/Java-linux/android-sdk-linux/platform-tools$ sudo ./adb devices


* daemon not running. starting it now on port 5037 *

* daemon started successfully *

List of devices attached

15c61631device



注意  15c61631device 这行就是我们的识别到的小米手机了。哈哈


然后在Eclipse下面的DDMS 去折腾吧。


你可能感兴趣的:(android,ubuntu,小米手机)