1. 查看手机ID号。
charlesxue@THSHIBA:~/setup/cocos2d-x/cocos2d-x-2.1.4/projects/simpleGame/proj.android/bin$ lsusb Bus 001 Device 002: ID 10f1:1a19 Importek Bus 001 Device 003: ID 0bda:0159 Realtek Semiconductor Corp. Digital Media Card Reader Bus 002 Device 005: ID 05c6:9031 Qualcomm, Inc. Bus 002 Device 003: ID 0bda:8197 Realtek Semiconductor Corp. RTL8187B Wireless Adapter Bus 006 Device 002: ID 062a:4101 Creative Labs 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
想知道哪个是手机的usb口,很简单的办法就是插上手机执行一下lsusb命令,然后拔掉手机再次执行一下lsusb比较一下打印结果。
2.写驱动配置文件。
读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 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/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
比如我的手机是motorola,idVender是22b8
那么这一行就是
SUBSYSTEM=="usb", SYSFS{idVendor}=="22b8", MODE="0666"
不过,你可以写多行。
所用到命令:
sudo vim /etc/udev/rules.d/50-android.rules 文件里添加如下配置参数: SUBSYSTEM=="usb", SYSFS{idVendor}=="0bb4", MODE="0666" 保存,给配置文件设置下权限 sudo chmod a+r /etc/udev/rules.d/51-android.rules 重启: sudo /etc/init.d/udev restart 最后再重启下adb服务,就可以了(没配置环境变量的请进入Android SDK tools目录执行sudo ./adb kill-server ./adb devices) sudo adb kill-serversudo adb devices 修改/etc/udev/rules.d/51-android.rules不需要重启Linux机器,重新插拔一下设备就可以了。再次运行adb devices就可以看到你的设备已经连接
VIM的安装:
apt-get install vim
参考资料:
http://www.cnblogs.com/onlycxue/p/3460542.html
http://www.androidonline.net/article/html/3511.html