Environment
- Vagrant
- VirtualBox
- ホストOS: macOS Sierra 10.12.4
- ゲストOS: Ubuntu 14.04
Problem
VagrantとVirtualBoxでUbuntu環境を構築し、Android端末をつないで、Ubuntu上でadb
のshell
やlogcat
コマンドを実行すると、結果が返ってこない(hanging)する場合があった。
Solution
stackoverflowで同様の問題があがっており、解決法も書いてあった。
adb can list devices but adb shell/logcat doesn't work
I had the exact same problem with adb shell hanging. I am running an Ubuntu 12.04 VM guest on an Ubuntu host. The problem for me was the USB Compatibility setting for the VM was set to 1.1, it needs to be at least 2.0. To change the setting power down the VM and choose the "Edit virtual machine settings" in the VMPlayer startup menu. Then select the "USB Controller" device and change "USB Compatibility" to USB 2.0.
要は、VMのUSBコントローラの設定を2.0
以上に上げればよいということ。
具体的な手順
1. VirtualBoxのゲストOSを電源オフ状態にする
$ vagrant halt
2. 最新のVirtualBox
とOracle VM VirtualBox Extension Pack
をインストールする
以下のサイトからダウンロードして、インストールする。
http://www.oracle.com/technetwork/server-storage/virtualbox/downloads/index.html?ssSourceSiteId=otnjp#extpack
3. VirtualBoxの設定でUSBコントーラを2.0にする
- VirtualBox > 設定 > ポート > USB
- USB 2.0 (EHCI)コントローラーにチェック
4. Vagrantを起動する
$ vagrant up