Signing the Android Application Package
This section describes the integrated publishing workflow to sign the APK provided by Visual Studio. In Preparing an App for Release the Archive Manager was used to build the app and place it in an archive for signing and publishing. This section explains how to create an Android signing identity, create a new signing certificate for Android applications, and publish the archived app ad hoc to disk. The resulting APK can be sideloaded into Android devices without going through an app store.
In Archive for Publishing, the Distribution Channel dialog presented two choices for distribution. Select Ad-Hoc:
Create a New Certificate
After Ad-Hoc is selected, Visual Studio opens the Signing Identity page of the dialog as shown in the next screenshot. To publish the .APK, it must first be signed with a signing key (also referred to as a certificate).
An existing certificate can be used by clicking the Import button and then proceeding to Sign the APK. Otherwise, click the click the + button to create a new certificate:
The Create Android Key Store dialog is displayed; use this dialog to create a new signing certificate that can use for signing Android applications. Enter the required information (outlined in red) as shown in this dialog:
The following example illustrates the kind of information that must be provided. Click Create to create the new certificate:
The resulting keystore resides in the following location:
C:\Users\USERNAME\AppData\Local\Xamarin\Mono for Android\alias\alias.keystore
For example, the above steps might create a new signing key in the following location:
C:\Users\USERNAME\AppData\Local\Xamarin\Mono for Android\chimp\chimp.keystore
Be sure to back up the resulting keystore file in a safe place – it is not included in the Solution. If you lose your keystore file (for example, because you moved to another computer or reinstalled Windows), you will be unable to sign your app with the same certificate as previous versions.
For more information about the keystore, see Finding your Keystore's MD5 or SHA1 Signature.
Sign the APK
When Create is clicked, a new key store (containing a new certificate) will be saved and listed under Signing Identity as shown in the next screenshot. To publish an app on Google Play, click Cancel and go to Publishing to Google Play. To publish ad-hoc, select the signing identity to use for signing and click Save As to publish the app for independent distribution. For example, the chimp signing identity (created earlier) is selected in this screenshot:
Next, the Archive Manager displays the publishing progress. When the publishing process completes, the Save As dialog opens to ask for a location where the generated .APK file is to be stored:
Navigate to the desired location and click Save. If the key password is unknown, the Signing Password dialog will appear to prompt for the password for the selected certificate:
After the signing process completes, click Open Folder:
This causes Windows Explorer to open the folder containing the generated APK file. At this point, Visual Studio has compiled the Xamarin.Android application into an APK that is ready for distribution. The following screenshot displays an example of the ready-to-publish app, MyApp.MyApp.apk:
After the application package has been signed for release, it must be published. The following sections describe several ways to publish an application.