首页 > 代码库 > 小米2S 连接Ubuntu Android Studio

小米2S 连接Ubuntu Android Studio

1. 首先打开手机上的开发者选项,USB调试。拨号:*#*#717717#*#*  ,手机会以Toast形式出现“……enable”字样。再次拨号可disable。

2. Ubuntu安装mtpfs;用lsusb命令查看当前usb端口占用;

3.手机连上电脑,再次lsusb,对比上次,新增的ID即小米手机usb ID。找到手机的连在电脑上的usb接口号:

wy@wy-Inspiron-7420:~/Downloads/android-studio/sdk/platform-tools$ lsusbBus 001 Device 002: ID 8087:0024 Intel Corp. Integrated Rate Matching HubBus 002 Device 002: ID 8087:0024 Intel Corp. Integrated Rate Matching HubBus 003 Device 008: ID 2717:9039  Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hubBus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hubBus 003 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hubBus 004 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hubBus 001 Device 003: ID 0bda:0129 Realtek Semiconductor Corp. Bus 001 Device 004: ID 1bcf:2897 Sunplus Innovation Technology Inc. Bus 002 Device 003: ID 8087:07da Intel Corp. 

可知小米2s是 Bus 003 Device 008: ID 2717:9039

4. $ sudo vim /etc/udev/rules.d/70-persistent-net.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"

保存退出。

5. 进入android sdk 文件夹下面/platform-tools,运行如下指令:

wy@wy-Inspiron-7420:~/Downloads/android-studio/sdk/platform-tools$ sudo ./adb kill-serverwy@wy-Inspiron-7420:~/Downloads/android-studio/sdk/platform-tools$ sudo ./adb devicesList of devices attached d14a12fb    unauthorized

6. 进入~/.android目录,在adb_usb.ini中添加如下设备号:

0x2717

最后结果是:

wy@wy-Inspiron-7420:~$ cd ~/.android/wy@wy-Inspiron-7420:~/.android$ cat 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.0x2717wy@wy-Inspiron-7420:~/.android$ 

7. 重启adb服务:

wy@wy-Inspiron-7420:~/Downloads/android-studio/sdk/platform-tools$ sudo ./adb kill-serverwy@wy-Inspiron-7420:~/Downloads/android-studio/sdk/platform-tools$ sudo ./adb devicesList of devices attached d14a12fb    device

 

完毕。然后可在Android Studio中选择小米2S进行调试了:

 

小米2S 连接Ubuntu Android Studio