Saved for later

Remote Debugging Android

How to debug on your android phone from within a virtual machine without USB.

Method that did not work all the way

Our first semi successful attempt was to tunnel the connection to ADB using ssh:

ssh -L 5037:localhost:5037

This worked for most ADB commands, however once the debugging started a lot more ports needed to be tunneled which was unknown beforehand.

The Wireless Method

Step 1, enable wireless debugging on your device. Go to settings and then developer options where you check the USB debugging and ADB over network.

Developer options

Step 2, on your development machine connect ADB to your device.

./adb connect

Make the IP address the same as displayed in the device.

Update, Android 4.2

With android 4.2 you can no longer connect remotely without a previous key negotiation. This is now done when you connect via USB.

If you like me are unable to connect via from within the virtual machine you will need root on your android to fix it.

From the development machine, copy the single line from $HOME/.android/

QAAAAJk..................QA= @myhost

And append it to /data/misc/adb/adb_keys on your android device. adb_keys contain one key per line so if you previously have paired any other machines they will show up here.

Restart the device and you are ready to go.