Google Xamarin: How to sign an Android APK file in Visual Studio for Mac for beginners | SubramanyamRaju Xamarin & Windows App Dev Tutorials

Thursday, 19 December 2019

Xamarin: How to sign an Android APK file in Visual Studio for Mac for beginners

Introduction:
After an application has been coded and tested, it is necessary to prepare a package for distribution. The first task in preparing this package is to build the application for release, which mainly entails setting some application attributes. In this article, we can learn how o sign Android APK in Visual studio for Mac.

Description:
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 side-loaded into Android devices without going through an app store. So please follow steps below
Step 1:
Make sure your android project running configuration to "Release"
Step 2:
Right click on your android project and then tap on "Archive for Publishing"
Step 3:
You may get below dialog to disable shared runtime
So you need to uncheck Shared Mono Runtime from android project options like below

Step 4: So now repeat step 2 for "Archive for Publishing" and tap on "Sign and Distribute"

Dialog presented us with two choices for distribution. Select Ad-Hoc and click Next:

From here, it is possible to select the distribution channel:
Ad-Hoc: Saves a signed APK to disk so it can be sideloaded to Android devices. This is a good way to create an APK for testing.
Google Play: Publishes a signed APK to Google Play.


Step 5: Create New Certificate
After clicking Ad-Hoc, Visual Studio for Mac opens the Android Signing Identity dialog as shown in the next screenshot. To publish the .APK, it must first be signed it with a signing key (also referred to as a certificate). If a certificate already exists, click the Import an Existing Key button to import it and then proceed to Sign the APK Otherwise, click the Create a New Key button to create a new certificate:

The Create New Certificate dialog is used to create a new signing certificate that can be used for signing Android applications. Click OK after entering in the necessary information:
The resulting keystore resides in the following location: ~/Library/Developer/Xamarin/Keystore/alias/alias.keystore
For example, the above steps might create a new signing key in the following location: ~/Library/Developer/Xamarin/Keystore/subbuarticles/subbuarticles.keystore
You can also above path by right click on your certificate and tap on "Show alias info" like below
Note: Be sure to back up the resulting keystore file and password 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 macOS), you will be unable to sign your app with the same certificate as previous versions.

Step 6: Sign the APK
After creating certificate, To publish an app on Google Play, click Cancel and go to Publishing to Google Play. Otherwise click Next.


Step 7:Publish as Ad Hoc
The Publish as Ad Hoc dialog provides a summary of the signed app before it is published. If this information is correct, click Publish.

The Output APK file dialog will save the APK to the path specified. Click Save.
Next, enter the password for the certificate (the password that was used in the Create New Certificate dialog) and click OK:
The APK is signed with the certificate and saved to the specified location. Click Reveal in Finder:
This opens the finder to the location of the signed APK file:

The APK is ready to copy from the finder and send to its final destination. It's a good idea to install the APK on an Android device and try it out before distribution

You can also see demo of this article from below youtube video. Also for more videos please don't forget to SUBSCRIBE our youtube channel from here.
FeedBack Note: Please share your thoughts, what you think about this post, Is this post really helpful for you? I always welcome if you drop comments on this post and it would be impressive.

Follow me always at @Subramanyam_B

1 comment:

  1. With the new policy from Google Play Console we need to let Google sign this bundle. How to upload the above signed .aab? The SHA1 fingerprint dont match.

    ReplyDelete

Search Engine Submission - AddMe