linux下Eclipse连接真机调试Android应用程序

首先真机不连电脑,运行一下命令lsusb,结果如下:

1 Bus 007 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub

2 Bus 006 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub

3 Bus 005 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub

4 Bus 004 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub

5 Bus 003 Device 002: ID 046d:c018 Logitech, Inc. Optical Wheel Mouse

6 Bus 003 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub

7 Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

8 Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

真机连上电脑,再次运行lsusb,结果如下:

1 Bus 007 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub

2 Bus 006 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub

3 Bus 005 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub

4 Bus 004 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub

5 Bus 003 Device 002: ID 046d:c018 Logitech, Inc. Optical Wheel Mouse

6 Bus 003 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub

7 Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

8 Bus 001 Device 009: ID 0bb4:0c02 High Tech Computer Corp. Dream / ADP1 / G1 Phone (Debug)

9 Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 001 Device 009: ID 0bb4:0c02 High Tech Computer Corp. Dream / ADP1 / G1 Phone (Debug)即为连接的真机设备。

接下来问题就简单了,按照以下步骤操作,就能得到我们想要的结果。
1、
1 sudo vim /etc/udev/rules.d/51-android.rules
 
  
在文件中添加如下内容:
1  UBSYSTEM=="usb", SYSFS{idVendor}=="0bb4", MODE="0666
 
  
"0bb4"即为上面的真机的ID,实际操作只需替换该部分就行了。
2、
1 sudo chmod a+r /etc/udev/rules.d/51-android.rules
 
  
3、重启udev事件。
1 sudo /etc/init.d/udev-post reload

4、进入adb所在目录.
1 /home/android/android-sdk/android-sdk-linux/platform-tools
 
  
具体路径还要根据个人实际情况来操作。
紧接着进行下面两步操作:
1 sudo ./adb kill-server

2 sudo ./adb devices
 
  
得到结果如下:
1 * daemon not running. starting it now on port 5037 *

2 * daemon started successfully *

3 List of devices attached 

4 0123456789ABCDEF    device
 
  
大功告成,真机连接成功!!

你可能感兴趣的:(android)