Signing your Xamarin.Android application package during the development phase

When you create an application using Xamarin.Android (or even if you use other tools such as Android Studio), it’s necessary to sign the application package (APK) to publish your application on the Google Play Store.

If you don’t know how how to proceed, Xamarin has published a step-by-step tutorial which explains how to achieve this goal.

This article is very useful when your application is finished, because it explains how to use the built-in tools to archive, sign and distribute your application.

But when you’re still in the development phase (e.g. to implement and test push notifications), it’s not convenient to use this workflow.

Fortunately, a more simple way to reach the same goal exist and is very easy to implement. Let’s take a look to this process.

Create a new keystore/certificate

The first step to sign an application is to generate a keystore, the container for the certificate associated to your application.

There are different ways to generate a keystore (e.g. command-line tools), but my preferred way is to use the GUI available in Xamarin Studio. To access this screen, go to Xamarin Studio > Preferences > Android Signing Keys.

Xamarin - Android Signing Keys

This screen lists all the keystores that you created on your computer. You are also able to import an existing keystore, or generate a new one by clicking to Create a new key.

When you create a new new key, you just have to complete some information on who you are (firstname, lastname, organisation…) and the security of your certificate (alias, password and validity).

Xamarin - Android Create Keystore

Once you created the new key, it’s stored in the folder ~/Library/Developer/Xamarin/Keystore/Your-Alias (if you’re using a Mac).

Sign your package with the keystore

The second (and last) step to sign your package is to associate the keystore to your project.

Once your project is open in Xamarin Studio, go to Project Options > Android Package Signing.

Check the box labeled “Sign the .APK file using the following keystore details” and fill the details with information used when you created the keystore.

If you have used the GUI to create the keystore, you probably noticed that there’s only one password value while there are 2 values (keystore password and alias password) in this screen. The GUI use the same value for both fields, but it’s possible to use different values if you use command-line tools.

Xamarin - Android Package Signing

Please note that it’s possible to use different keystores for debug and release modes. You can switch between these modes using the configuration list on the top of the dialog box.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s