ubuntu 下正確安裝android手機驅動

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


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章