小米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$ lsusb Bus 001 Device 002: ID 8087:0024 Intel Corp. Integrated Rate Matching Hub Bus 002 Device 002: ID 8087:0024 Intel Corp. Integrated Rate Matching Hub Bus 003 Device 008: ID 2717:9039 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:0002 Linux Foundation 2.0 root hub Bus 004 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub Bus 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-server wy@wy-Inspiron-7420:~/Downloads/android-studio/sdk/platform-tools$ sudo ./adb devices List 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. 0x2717 wy@wy-Inspiron-7420:~/.android$
7. 重启adb服务:
wy@wy-Inspiron-7420:~/Downloads/android-studio/sdk/platform-tools$ sudo ./adb kill-server wy@wy-Inspiron-7420:~/Downloads/android-studio/sdk/platform-tools$ sudo ./adb devices List of devices attached d14a12fb device
完毕。然后可在Android Studio中选择小米2S进行调试了:
此后每次开机或者连接手机,重启一次adb服务即可,即第7步。
在终端运行./adb devices的时候,在手机上点确认,同意此PC以调试模式连接手机。