Skip to content
Home » Private: Blog » Publishing Xamarin.Forms.Android Application to Google Play

Publishing Xamarin.Forms.Android Application to Google Play

So, I recently had to publish a Xamarin.Forms.Android Application to Google Play. I experienced a few bumps along the way, but finally succeeded this very evening.

Preparing the .APK

First of all, you want to make sure that you disable debugging, specifiy an application icon, version the application and configure your linker.

Afterwards, you’ll need to build the package in Release mode. No problem, right?

Well, I personally experienced a “COMPILETODALVIK : UNEXPECTED TOP-LEVEL” error while doing so, which, apparently was related to Xamarin.Forms.Maps.

If you experience this issue, it can either be due to missing permissions in your Android Manifest or the Heap Size. This is all explained in the previous forum discussion.

After resolving the error, I was finally able to clean & rebuild the solution.

Signing the .APK

Now, for signing the .APK, instead of using the command line tools, you can simply use the tools provided in Visual Studio.

Simply navigate to “Tools” –> Android” –> “Publish Android App…” in the Visual Studio menu, and select “Create new keystore”.

After you have created your keystore, select where you want your signed .apk to be built to and click “Publish”.

Publishing the .APK

Now, in your “bin/Release” folder, you will have two .apk files generated.

So, here I was, thinking to myself, that I could simply upload the signed version of the .APK.

But alas, when I tried to do so, I was told (no matter what I did) that the .APK was, to my amazement, not zipaligned correctly.

I also did try to upload the aligned .APK which was generated from the publishing process, but to no avail.

So, before I was able to publish, I needed to zipalign the signed version of the .APK.

So, what I did was to grab a copy of the .APK which said “Signed” under “bin/Release”.

I then navigated to where my Androd SDK was located, and jumped into “android-sdk\build-tools\<version>” and for ease, pasted my .APK here.

Note: if you are unable to locate this folder, you probably havn’t insstalled the build tools. You can install the build tools in Visual Studio under the Android SDK Manager.

I then popped open a terminal and navigated to the build tools folder, and typed in the followng command (I, ofcourse, replaced “helloworld” with the name of my application):

zipalign.exe -f -v 4 mono.samples.helloworld-Signed.apk helloworld.apk

Afterwards, I was finally able to upload my .APK to the Google Play Store.

Victory!

// Dave

3 thoughts on “Publishing Xamarin.Forms.Android Application to Google Play”

    1. Hello Priya,
      You should be able to find the output file (referred to as “helloworld.apk” in this guide) in the same directory as the input file (e.g. “mono.samples.helloworld-Signed.apk”). Just remember that the output file should have a different name. In doing so, you should be all set.

      Best regards,
      David

Leave a Reply

Your email address will not be published. Required fields are marked *

This page is under construction