Android Hash Key Work only once

694 Views Asked by At

I am writing an application using Ionic and Phonegap and am running into a problem trying to integrate the Facebook plugin that you can get at https://github.com/Wizcorp/phonegap-facebook-plugin

I understand that I need to add a hash key to my Facebook developer account (release and debug mode) and have done this following the processes outlined at http://developer.android.com/tools/publishing/app-signing.html

I build and push my app to android using Cordova build android or Phonegap build android and the app is happily built and pushed to my phone.

The app is running along and the plugin API is working because it opens up the facebook app to authenticate but I get the error message. Facebook Invalid key hash. The key hash xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx does not match any stored key hashes. Configure your app key hashes at etc..

I have tried manually dropping the debug-unaligned,Still not working

Can anyone help me out or point me in the right direction?

1

There are 1 best solutions below

2
On

In Android you can generate HASH KEY by below code:

public void generateFacebookHashKey()
    {

        try
        {
            PackageInfo info = getPackageManager().getPackageInfo("Your package name", PackageManager.GET_SIGNATURES);
            for (Signature signature : info.signatures)
            {
                MessageDigest md = MessageDigest.getInstance("SHA");
                md.update(signature.toByteArray());
                Log.d("TEMPTAGHASH KEY:", Base64.encodeToString(md.digest(), Base64.DEFAULT));
            }
        }
        catch (NameNotFoundException e)
        {

        }
        catch (NoSuchAlgorithmException e)
        {

        }

    }

Check this Hashkey and key which you used in facebook developer account are same or not ?

If not then you are using wrong key.

Hope it will help you.