歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Linux編程 >> Linux編程 >> 關於Android真機測試(Linux系統下)

關於Android真機測試(Linux系統下)

日期:2017/3/1 10:41:39   编辑:Linux編程

今天測試程序,在虛擬機上運行出問題,於是用真機來測試,但是發現Ubuntu下不認。。調用./adb devices顯示如下。。結果無法用真機測試。

List of devices attached
emulator-5554 device
???????????? no permissions

google小米真機測試無果,google ubuntu Android 真機測試找到了線索(http://www.linuxidc.com/Linux/2011-04/34131.htm),可是又納悶了,他列出的設備代碼沒有小米手機,繼續google,無果,然後自己想辦法,先列出解決辦法:

首先手機不連電腦,運行一下命令lsusb,結果如下:

  1. alfredtofu@alfredtofu-laptop:~/myapp/eclipse/android-sdk-linux_x86/platform-tools$ lsusb
  2. Bus 002 Device 002: ID 8087:0024
  3. Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
  4. Bus 001 Device 009: ID 093a:2510 Pixart Imaging, Inc. Hama Optical Mouse
  5. Bus 001 Device 004: ID 058f:b002 Alcor Micro Corp.
  6. Bus 001 Device 002: ID 8087:0024
  7. Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

手機連上電腦,再一次lsusb,結果如下:

  1. alfredtofu@alfredtofu-laptop:/$ lsusb
  2. Bus 002 Device 005: ID 18d1:9025
  3. Bus 002 Device 002: ID 8087:0024
  4. Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
  5. Bus 001 Device 009: ID 093a:2510 Pixart Imaging, Inc. Hama Optical Mouse
  6. Bus 001 Device 004: ID 058f:b002 Alcor Micro Corp.
  7. Bus 001 Device 002: ID 8087:0024
  8. Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

對比發現,多了Bus 002 Device 005: ID 18d1:9025,跟那個參考網站一對比,發現18d1正是設備ID,接下來問題就輕松解決了。

sudo vim /etc/udev/rules.d/51-android.rules

添加一下內容:

UBSYSTEM=="usb", SYSFS{idVendor}=="18d1", MODE="0666"

以上命令不同手機只需要改SYSFS{idVendor}=="18d1",中的18d1,至於這個代碼怎麼找,上面介紹了。

sudo chmod a+r /etc/udev/rules.d/51-android.rules

sudo /etc/init.d/udev restart

sudo ./adb kill-server

sudo ./adb devices

最終結果顯示如下:

  1. * daemon not running. starting it now on port 5037 *
  2. * daemon started successfully *
  3. List of devices attached
  4. emulator-5554 device
  5. 00c49bd2 device

於是可以用真機測試了。

Copyright © Linux教程網 All Rights Reserved