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.
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:
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:
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
- Swipe down from the top of the screen and tap the Settings icon.
- Tap Wi-Fi.
- Tap and hold your current Wi-Fi network. Select Modify Network.
- Tap the Show advanced options box.
- Tap the Proxy settings dropdown and select Manual.
- Type the IP address and port (usually 8888) of the Fiddler server.
- 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.