user2045814
user2045814

Reputation:

Generating hash key for facebook development

I have recently started working on facebook API, where I came under the situation of generating Hash key and registering it on facebook for further use.

For that, I used the following code

PackageInfo info;
try {
    info = getPackageManager().getPackageInfo("com.you.name", PackageManager.GET_SIGNATURES);
    for (Signature signature : info.signatures) {
        MessageDigest md;
        md = MessageDigest.getInstance("SHA");
        md.update(signature.toByteArray());
        String something = new String(Base64.encode(md.digest(), 0));
        //String something = new String(Base64.encodeBytes(md.digest()));
        Log.e("hash key", something);
    }
} catch (NameNotFoundException e1) {
    Log.e("name not found", e1.toString());
} catch (NoSuchAlgorithmException e) {
    Log.e("no such an algorithm", e.toString());
} catch (Exception e) {
    Log.e("exception", e.toString());
}

All worked well, as I was able to work with facebook in my app.

But, after publishing the app on playstore, I found the error Invalid_Android_key parameter. The key does not match any allowed key Configure your app key hashes at https://developers.facebook.com/apps/..........

Please, let me know the cause of this problem and how to handle this.

Upvotes: 2

Views: 1003

Answers (1)

RaviPatidar
RaviPatidar

Reputation: 1486

I had same Problem, after creating the apk, the key hash is changed! because using this code u get the debug keystore hash, but when creating apk, it's another hash, gotta capture it from log after trying ur apk on emulator , then delete code and export again without this log , i know it's a hassle but for me it was easier than keytool...

Upvotes: 1

Related Questions