Some test text!

Hamburger Icon

Xamarin / FAQ / How do I reduce the size of my APK?

Building ABI-Specific APKs

For basic information on building multiple APKs for an application, consult Xamarin's documentation on Building ABI-Specific APKs. This article will discuss how to build an APK that will target a single ABI for sample project ContentPage.Droid.

First, install Ruby. You can test by typing gem or rake from your command prompt.

The rakefile is adapted from the original rakefile from Xamarin's documentation and made to work with ContentPage.Droid project. It performs each of the steps that were described in the official Xamarin's documentation:

  1. Create an android:versionCode for the APK.
  2. Write the android:versionCode to a custom AndroidManifest.XML for that APK.
  3. Compile a release build of the Xamarin.Android project that will singularly target the ABI and using the AndroidManifest.XML that was created in the previous step.
  4. Sign the APK with a production keystore.
  5. Zipalign the APK.
The script assumes there is a debug_keystore keystore file. Change to your own keystore file with corresponding password to try it out.

To build the split APKs for the sample app:

  • Open Developer Command Prompt for VS 2017
  • Run the build Rake task:
rake build
==> Building an APK for ABI x86 with ./Properties/AndroidManifest.xml.x86, android:versionCode = 60814120.
==> Building an APK for ABI armeabi-v7a with ./Properties/AndroidManifest.xml.armeabi-v7a, android:versionCode = 20814120.
  • You will find the output in:

Get the answers you need: Chat with us