This section of the tutorial explains you how to get Key Hashes for Android Facebook app. Facebook SDK integration to android require an key hash configuration.While integrating Facebook SDK, we need to configure Facebook API console with Key Hash. If key hash is missing you will get App mis-configured error in Facebook dashboard.

 

JavaFile MainActivity.java: – 

Add this Code in onCreate Method.

  try {

            PackageInfo info = getPackageManager().getPackageInfo(

                    getPackageName(),

                    PackageManager.GET_SIGNATURES);

            for (Signature signature : info.signatures) {

                MessageDigest md = MessageDigest.getInstance(“SHA”);

                md.update(signature.toByteArray());

                Keyhash = Base64.encodeToString(md.digest(), Base64.DEFAULT);

                Log.e(“KeyHash:”, Keyhash);

            }

        } catch (PackageManager.NameNotFoundException e) {

 

        } catch (NoSuchAlgorithmException e) {

  }