小米手机 连接在Ubuntu 下调试

来源:互联网 发布:用淘宝联盟招代理步骤 编辑:程序博客网 时间:2024/05/01 15:31

最近的一个项目需要用到linux开发Android程序! 发现Ubuntu有小米开发连接不上!  搞了一个下午才搞成功! 看看吧!


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

www.linuxidc.com@linuxidc:~$ lsusb

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

Bus 006 Device 002: ID 17ef:1003 Lenovo

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

Bus 005 Device 003: ID 046d:c06c Logitech, Inc.

Bus 005 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 003 Device 003: ID 0a5c:2110 Broadcom Corp. Bluetooth Controller

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

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

Bus 001 Device 005: ID 18d1:9025

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


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

www.linuxidc.com@linuxidc:~$ lsusb

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

Bus 006 Device 002: ID 17ef:1003 Lenovo

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

Bus 005 Device 003: ID 046d:c06c Logitech, Inc.

Bus 005 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 003 Device 003: ID 0a5c:2110 Broadcom Corp. Bluetooth Controller

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

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

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


对比发现,Bus 001 Device 005: ID 18d1:9025   就是小米手机的

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

SUBSYSTEM=="usb", SYSFS{idVendor}=="04e8", MODE="0666"

SUBSYSTEM=="usb", ATTR{idVendor}=="04e8", ATTR{idProduct}=="685e", SYMLINK+="android_adb"

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

www.linuxidc.com@linuxidc:/etc/udev/rules.d$ sudo service udev restart    //or restart udev

udev start/running, process 7147


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

www.linuxidc.com@linuxidc:~/star2011/SDK/android-sdk-linux/platform-tools$ sudo ./adb kill-server

www.linuxidc.com@linuxidc:~/star2011/SDK/android-sdk-linux/platform-tools$ sudo ./adb devices

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

* daemon started successfully *

List of devices attached


然后,就可以直接用adb  shell操作了.也可以用Eclipse来调试。


原创粉丝点击