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.
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:
MySolution |-src |-MyAndroidProject |-tools |-Deploy-X86App.ps1
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:
C:\Program Files (x86)\Microsoft Visual Studio\201X\Community\MSBuild\xx.x\Bin
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
In addition it is possible to provide default values for any script parameter by modifying the script’s
Deploy-X86App.ps1 utility script first builds a x86 apk by using
msbuild, then it signs and zipaligns the generated apk by using respectively
zipalign which is finally deployed in the target emulator via the
These steps are described in detail in the Build ABI Specific APKs document.
PowerShell is, in my opinion, the best scripting platform available today. It has been helpful many times more than once to perform and automate repeatable tasks.