I have a virtual machine with Windows 8 and Android Studio where I am currently experimenting with Android mobile development. I tried Eclipse as well but eventually decided to use Android Studio for a number of reasons which I won’t get into now because it is not relevant for this post.
Anyhow my problem with Eclipse and Android Studio is the emulator. It needs a lot of time to start and it crashes often. So I tested this week to run my sample app directly on an Android phone and it makes a huge difference for a faster development and testing, the app is loaded on the phone in a very short time.
The tricky part was though that I am developing in a virtual machine environment and the phone that I would be testing the app on is connected via USB to the main machine. Getting this to run wasn’t as difficult as I expected.
1. Virtual machine with Windows 8 and Android Studio running in VMWare Player
- Enable debugging on the Android device:
- On your Android device, go to Settings -> Develop Option -> check USB Debugging
- Enable unknown sources on the Android device:
- On your Android device, go to Settings -> Security -> check Unknown sources
- Connect the Android device via USB to the main machine: Windows on the main machine should recognize the phone.
- Install the driver for the Android device in the virtual machine:
- Go to the phone manufacturer’s website, download the latest driver for the phone and install it in the virtual machine.
- Make sure that the Android device is displayed correctly in the Device Manager. Windows might also automatically install some driver but that’s not enough.
- Connect the Android device in the virtual machine:
- In VMWare Player, go to the menu Player -> Removable devices: the Android device should be listed here.
- Go to the Android device and select the menu item Connect.
- Run the Android app on the device:
- Go to Android Studio and press “Run app”: the “Choose device” dialog should list the connected Android device under “Choose a running device”.
- Select “Choose a running device”, if not already selected, and select the connected device.
- Check “Use same device for future launches”, if you don’t want this dialog to pop up every time you run the app. This way Android Studio will automatically open the app on the connected device.
- Click OK.
- That’s it! You should see your Android app running on your connected device.