今天给公司一同事的小米2s装我们的开发的应用,发现连上ubuntu后不能debug,后来查资料,搞定了,现分享如下:
先安装几个库:
root@clq-ubuntu:~# sudo apt-get install mtpfs libfuse-dev libmad0-dev
然后尝试挂载设备:(我本身就是root角色,后面我都省略了sudo 这个前缀)
root@clq-ubuntu:~# sudo mkdir /media/mtp
root@clq-ubuntu:~# sudo chmod 775 /media/mtp
root@clq-ubuntu:~# sudo mtpfs -o allow_other /media/mtp
获取设备号码:
root@clq-ubuntu:~# lsusb
Bus 002 Device 009: ID 2717:9039
Bus 002 Device 002: ID 8087:0024
Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 001 Device 004: ID 04f2:b257 Chicony Electronics Co., Ltd
Bus 001 Device 003: ID 046d:c05a Logitech, Inc.
Bus 001 Device 002: ID 8087:0024
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
小米2s是我最后连上的,故主设备号为:
2717
设置android的usb配置:
root@clq-ubuntu:~# cd ~/.android
root@clq-ubuntu:~/.android# vi adb_usb.ini
在adb_usb.ini最后添加上:
0x2717
保存退出
然后,编辑规则
root@clq-ubuntu:~/.android# cd /etc/udev/rules.d
root@clq-ubuntu:/etc/udev/rules.d# ls
70-persistent-cd.rules 70-persistent-net.rules README
root@clq-ubuntu:/etc/udev/rules.d# vi /etc/udev/rules.d/51-android.rules
添加如下内容:
SUBSYSTEM=="usb", ATTR{idVendor}=="2717", MODE="0666"
让配置生效:
root@clq-ubuntu:/etc/udev/rules.d# /etc/init.d/udev restart
root@clq-ubuntu:/etc/udev/rules.d# chmod a+rx /etc/udev/rules.d/51-android.rules
root@clq-ubuntu:/etc/udev/rules.d# service udev restart
然后进入andriod-sdk的目录下,用adb查看,便可以看到设备了:
root@clq-ubuntu:/developer/android-sdk-linux/platform-tools# ./adb kill-server
root@clq-ubuntu:/developer/android-sdk-linux/platform-tools# ./adb devices
* daemon not running. starting it now on port 5037 *
* daemon started successfully *
List of devices attached
5d6c5e1 offline