So today was another learning experience indeed.  I decided to try Xamarins own Android Emulator today.  I’ve had so many odd problems with the Google Android Emulator that I was getting a bit fed up with using it to be honest.  It seems to have a lot of small issues that make it a pain to use and it has some major issues that under certain circumstances means it won’t work at all.

Anyway, the installation went without a hitch, needed to reboot to get the Host-Only network driver working.  Then I hit a road-block.

I was trying to configure the emulator to use Fiddler as a proxy on the development machine.  In the Google emulators you can configure a proxy using the APN settings for the cellular provider but this isn;t present in the Xamarin emulator so I’ve spent far longer than I should have trying to figure this one out.

By default all the emulators sit behind a virtual router, meaning if you have several emulators running they won’t be able to see your development box nor each other.  They are running in a kind of virtual network environment and each instance is completely isolated on the network.  Add into that the additional abstraction of VirtualBox and you have a pretty complex environment to deal with.

Anyway, I have added in additional bindings to make my IISExpress web sites available over the network and I could contact the API using the IP address but this makes Fiddler ignore the traffic.

The Solution

So, in the Xamarin Emulator you need to setup the proxy settings in the WiFi configuration.

If you’re having lots of issues getting this to work it’s worth checking that VirtualBox has been configured properly during the installation.  For instance when I first installed it, it was configured to use a SubNet mask of 255.0.0.0 so there was no hope of ever getting it to work properly on my development box.  Unless you have a custom setup (which is highly unlikely) this should in fact be 255.255.255.0.

Check VirtualBox Network Settings

Open the VirtualBox application and check the network settings for VirtualBox (not your VM) go to File -> Preferences:

vbsettings

This will show you the adapters created for VirtualBox during the installation.  My particular system needs to be available on #2 so double click the adapter to check/change:

adaptersettings

When my system was initially set-up the IPv4 Network Mask was set to 255.0.0.0 meaning it couldn’t see my development box.  It very likely that if you are trying to connect things to your host development box you may need to check what your configuration is (most likely 255.255.255.0) and then set VirtualBox to use the same mask (ipconfig is your friend).

Configuring the Xamarin Android Player

  1. Swipe down from the top of the screen and tap the Settings icon.
  2. Tap Wi-Fi.
  3. Tap and hold your current Wi-Fi network. Select Modify Network.ModifyNetwork
  4. Tap the Show advanced options box.ShowAdvancedOptions
  5. Tap the Proxy settings dropdown and select Manual.IPAddress
  6. Type the IP address and port (usually 8888) of the Fiddler server.IP Address
  7. Tap Save.

To verify this configuration, go to http://ipv4.fiddler:8888/. You should see the Fiddler Echo Service webpage, and the traffic should appear in Fiddler.

This is all tested and working as expected now.

View IISEXpress Hosted Sites On Your Local Network
Xamarin Android AXML Intellisense

Discussion

  • Commenter's Avatar
    /anon — July 24, 2015 at 7:56 am

    Great post. Searched the internet far and wide to find out how to do this. Big Help!

  • Commenter's Avatar
    anon2 — November 25, 2015 at 1:22 am

    You selected android version what is?

  • Commenter's Avatar
    jammer — December 3, 2015 at 4:20 pm

    I’m not sure I understand the question, although at the moment this is compiled against API 21 with a minimum version of API level 15.

  • Commenter's Avatar
    Thomas Burkhart — May 30, 2016 at 4:25 pm

    Hi Jammer,
    could you please tell me which settings you used for the network adapters? LocalHost/NAT/ etc?

    I fear I messed up my basic inatsllation when trying to connect to an Ubuntuserverimage in VirtualBox.

    Best
    Thomas

  • Commenter's Avatar
    jammer — June 1, 2016 at 8:54 am

    Hi Thomas,

    The VirtualBox NAT view is empty, there isn’t any need for NAT configuration to get this scenario working. The complete configuration for the VirtualBox adapters are:

    #1
    IP v4: 0.0.0.0
    IP v4 Mask: 15.0.0.0
    Address: 192.168.56.100
    Server Mask: 255.255.255.0
    Lower: 192.168.56.101
    Upper: 192.168.56.254

    #2
    IP v4: 10.71.34.1
    IPv4 Mask: 255.255.255.0
    Address: 10.71.34.2
    Server Mask: 255.255.255.0
    Lower: 10.71.34.101
    Upper: 10.71.34.199

    Hope this helps!

Leave a Comment

Your email address will not be published. Required fields are marked *

*

This site uses Akismet to reduce spam. Learn how your comment data is processed.