Mobile Device Testing and Debugging with VirtualBox, Android Studio, Visual Studio and IIS

This post is from the perspective of a person who has a Microsoft technologies based web solution that needs to connect with a mobile device. This might work for other types of technologies and virtual machines with some or alot of tuning. Basic principles should be more or less the same.

I will give firstly an introduction on the solution used in my scenario:

I have a Android mobile device with an app in it that needs to connect to a webapi service to retrieve data and post data to it. The thing which this post is concerned about, is debugging the app with Android studio using the app from the Android device against a webapi which is also under debug mode in Visual Studio. This way I can see what is happening both on the client and on the server side.

Basically how this works is that you will have to connect with your mobile device to a local network where your physical machine exists. Because you are using a mobile device the logical way is over WiFi and no having your device plugged in to your physical machine by USB does not work. You can not directly connect to a localhost that way. Well atleast I could not make it to work. Notice that you can connect to a localhost from Android Studio while debugging your Android app but this is only possible is your a emulating the app locally. Even then though you might have problems and have to configure your solution in such a way that your app will pick it up.

This post assumes that you have a ready build for your server side solution at a location in your development machine. Here are the steps:

1. Create IIS site

– Add a new application to IIS which points to your solution build location.
mobile1

mobile2

– Next make sure that the application pool account has enough privileges to the location. I do this by creating a new account to AD or I create a local machine account on my development machine.

This is to configure the Application Pool account:
mobile8

These steps are for the file system level:
mobile3

mobile4

– If you are using a database in your application make sure that the application pool account has the proper privileges. This depends of course on how you have built your solution.
– Assign a port to your web application

mobile6

mobile5

2. Config ports and firewall settings
– Next you need to allow inbound and outbound connections to you web application through the port which was earlier configured for the web application. This needs to be done for both the virtual machine and your actual physical machine.

For virtualBox:
mobile9

For WMWare:
mobile10
mobile11

3. Attach to process

The next steps is to attach your developer tools to your server solution and your mobile application to whatever developer tools your are using, something like Android Studio or XCode.

Config VirtualBox

How to Forward Ports to a Virtual Machine and Use It as a Server

 

Advertisements

VirtualBox, Android Devices and error “This device cannot start. (Code 10)”

Ok, if you get this error you are probably trying to install your Android device to windows and it fails. When checking the device manager you might see the following error code. There are numerous posts and instructions which might help you but none did to my LG G3. What eventually helped was an insight based on several different posts.

On my virtual machine the problem was related to the USB port type used in relation to the USB port actually used in your real world machine and USB cable used.

Basically as default the VirtualBox used USB 1.1 which for some reason does not work, probably something to do with my cable being USB 2.0. To fix my problem I installed the VirtualBox extension for USB: VM VirtualBox Extension Pack.

Then I changed the USB type to be used for the Virtual Machine to 2.0, booted my windows and it worked. So if you are getting the error above no matter where you are check that you have the proper USB cable which is compatible with your Android device and the port on your machine. For a virtual machine image check that you have the right USB configuration in relation to your real world devices.

If the case above does not work, then try this KB article from Microsoft:

https://support.microsoft.com/en-us/kb/943104