Saturday, April 28, 2018

Android - Hash Key of Application

Introduction: Register an Android application for a 3rd party like Facebook. We always need Hash key of APK. Here, i'm going to explain a simple code snippet that gets hash key of your debug and release Apk.

So, First of all, if you want Hash key of debugging apk just paste the following code snippet anywhere in your Java/Kotlin class.

public void generateKeyHash() {
     try {
            PackageInfo info = getPackageManager().getPackageInfo( getPackageName(),PackageManager.GET_SIGNATURES);
            for (Signature signature : info.signatures) {
                MessageDigest md = MessageDigest.getInstance("SHA");
                Log.d("KeyHash:", Base64.encodeToString(md.digest(), Base64.DEFAULT));
         } catch (PackageManager.NameNotFoundException e) {
         } catch (NoSuchAlgorithmException e) {
Now press ALT+6, You will see hash key in the log.

Now, If you want hash key of release Apk. You can do it with simple two steps.

1. The first step is the same as above.

2. Now generate release Apk. Install it in the device and connect it with android studio and press ALT+6. You will see Hash key as above. After that, you can delete code snippet and generate another singed build.

Get it on Google Play

Android - Scoped storage OS 11

Every Android updated version has something for developers and users alike. The Android 10 version has many user-friendly and performance en...