Deploying Xamarin Android Project to x86 emulator

At the time of this writing, there is no easy way to build an x86 APK from a Xamarin Android project from Visual Studio 2017.

I discovered this recently after coming across the need to deploy my application to an emulator running a x86 image. In fact, Visual Studio 2017 assumes that the used emulator runs an ARM image.

After some searching, I found the “Build ABI Specific APKs” document in the official Xamarin documentation that describes the multiple steps necessary to build a x86 apk.

After trying out the steps manually with success, it made sense to automate the process in a Powershell script.

The script is a available as a Github Gist and you can use it without restrictions.

In the following post, we will take a look at:

  • Where to place the script and What environment does it expect?
  • How to use the script?
  • What steps does it performs?



It is recommended to place this script somewhere under the solution folder, for example, under a “tools” folder as in the following directory tree:


The script assumes, of course, that the following “components” are properly installed and configured:

Furthermore, the script relies on the following programs to be reachable via the system’s (or user’s) PATH variable, here they are along with there common location:

  • msbuild C:\Program Files (x86)\Microsoft Visual Studio\201X\Community\MSBuild\xx.x\Bin
  • jarsigner C:\Program Files\Java\jdk1.x.x_xxx\bin
  • zipalign ~\AppData\Local\Android\sdk\build-tools\xx.x.x\
  • adb ~\AppData\Local\Android\sdk\platform-tools


First off, it is possible to view the documentation of the utility by using the Get-Help commandlet. The documentation contains details and usage examples.

The utility is used by providing a running emulator Id and a Xamarin Android project location:

.\Deploy-X86App.ps1 emulator-ID -ProjectPath src\MyApp

The scripts would normally accept a lot of arguments that can be tedious to type each time, fortunately most of them are initialized with nice defaults or are gathered from project files (such as the AndroidManifest.xml).

In addition it is possible to provide default values for any script parameter by modifying the script’s param statement.


The Deploy-X86App.ps1 utility script first builds a x86 apk by using msbuild, then it signs and zipaligns the generated apk by using respectively jarsigner and zipalign which is finally deployed in the target emulator via the adb utility.

These steps are described in detail in the Build ABI Specific APKs document.

Closing thoughts

PowerShell is, in my opinion, the best scripting platform available today. It has been helpful way more than once to perform and automate repeatable tasks.