Skip to content
Pascal Arnould By Pascal Arnould Software Engineer III

To quote Jack Burton in Big Trouble in Little China:

I'm a reasonable guy. But, I've just experienced some very unreasonable things.

Today my Xamarin trial expired - Sadface. But @endjin generously supplied me with a new Xamarin.Android and Xamarin.iOS Business edition license, things were looking up - Happyface. However after activating the new license and upgrading to a newer version of Xamarin Studio on both my Mac and the guest Windows 8 OS, my master solution containing all the projects for the different platforms (Android, iOS and Windows Phone) was no longer building. I'm not sure whether this really happened as a result of the license activation and/or the upgrade but I was once more in trouble with my Xamarin platform setup - Sadface!

Problem #1: Android project build failure

Building the project in Xamarin Studio on Windows threw this error: The "Aapt" task failed unexpectedly*.* No idea what this means but luckily the Xamarin forum had the answer. The problem is caused by an incomplete Android SDK install and more specifically missing Build-tools. To fix this, open the Android SDK Manager which can be found in %APPDATA%\Local\Android\android-sdk\SDK Manager.exe. or go to All Programs > Android SDK Tools > SDK Manager. Select the Android SDK Build-tools and install the missing package.

Azure Weekly is a summary of the week's top Microsoft Azure news from AI to Availability Zones. Keep on top of all the latest Azure developments!

After the installation completes, restart Xamarin/Visual Studio. Your Android project should now build successfully and you can move on to the next problem!

The best hour you can spend to refine your own data strategy and leverage the latest capabilities on Azure to accelerate your road map.

Problem #2: iOS emulator failure

After troubleshooting problem #1, I wanted to check whether the iOS app was still running on the emulator as it did before. However Xamarin on Windows could no longer communicate with the Mac build host. The iOS settings in Visual Studio under Tools > Options > Xamarin > iOS Settings appeared to be correct. The <HOSTNAME> was the same as it's always been.

201306192248.jpg

But when I clicked on Configure to open up the Xamarin.iOS build host dialog, I noticed two entries, one of which was unfamiliar. A quick check revealed that the local hostname on my Mac had changed (to find out your current hostname, you can start a new Terminal session and type in echo $HOST). So to fix my problem, all I had to do was to change the hostname back to what it was before. Under System Preferences, go to Sharing and click on the Edit button.

201306192303.jpg

201306192307.jpg

In the dialog, modify the Local Hostname to match the expected <HOSTNAME> in the Visual Studio Xamarin iOS Settings.

201306191903.jpg

As a side note, I also find out that the build server address, the Mac hostname and its IP address are stored in the Registry as shown below:

201306191902.jpg

201306191902.jpg

Problem solved and Happyface again!

FAQs

What causes the 'Aapt task failed unexpectedly' error when building Android projects? This cryptic error is usually caused by an incomplete Android SDK installation, specifically missing Build-tools. Open the Android SDK Manager (found in %APPDATA%\Local\Android\android-sdk\SDK Manager.exe or via All Programs > Android SDK Tools), select Android SDK Build-tools, and install the missing package. Restart Xamarin or Visual Studio after installation.
Why can't Visual Studio connect to the Mac build host for iOS development? The most common cause is that your Mac's local hostname has changed, often after a system update or network configuration change. Check your Mac's current hostname by running 'echo $HOST' in Terminal, then update System Preferences > Sharing > Edit to match the hostname expected in Visual Studio's Xamarin iOS Settings. The connection details are stored in the Windows Registry if you need to verify them.

Pascal Arnould

Software Engineer III

Pascal Arnould

He has over 20 years experience of implementing complex technology solutions across a number of sectors, and is a passionate advocate of Agile practices, continuous learning and engineering excellence.

Pascal worked at endjin from 2013 - 2015.