Tuesday, 6 March 2018

Generate Key for hash for facebook

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(



            for (Signature signature : info.signatures) {

                MessageDigest md = MessageDigest.getInstance("SHA");


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

                Log.e("KeyHash:", Keyhash);


        } catch (PackageManager.NameNotFoundException e) {


        } catch (NoSuchAlgorithmException e) {



No comments:

Post a Comment