How to solve this facebook key hash error?

2019-04-17 18:16发布

问题:

In my project, I am using facebook API for login purpose. I got key hash error , when ever i try different account or different mobile device. Any body known this type issue. How to solve this. In below, i attached error screenshot.

回答1:

public void generateHashkey(){
        try {
            PackageInfo info = getPackageManager().getPackageInfo(PACKAGE, PackageManager.GET_SIGNATURES);
            for (Signature signature : info.signatures) {
                MessageDigest md = MessageDigest.getInstance("SHA");
                md.update(signature.toByteArray());
                String s = Base64.encodeToString(md.digest(),
                        Base64.NO_WRAP);

                Log.e("HASH KEY ", s);
            }
        } catch (PackageManager.NameNotFoundException e) {
            Log.d("Name not found", e.getMessage(), e);

        } catch (NoSuchAlgorithmException e) {
            Log.d("Error", e.getMessage(), e);
        }
    }

try to generate the hashkey then copy paste it to developer console facebook.