签署Android应用程序后Facebook密钥哈希错误

时间:2014-05-14 18:10:05

标签: android facebook

我有一个集成了facebook的应用程序。当我从eclipse运行它时它工作正常但在签署应用程序后我得到了这个错误

 Login failed: invalid_key:Android key mismatch.
Your key "JGn9F2vDQ/w6hexLxdefCUpxYIA" does not match the allowed keys specified in your application settings.
Check your application settings at http://www.facebook.com/developers

我已检查过我的应用程序生成的密钥哈希值,并且www.facebook.com/developers上的密码哈希值相同。请帮忙!

2 个答案:

答案 0 :(得分:0)

您可以尝试使用此方法生成哈希键:

 // Put this code on oncreate method

try {
    //Replace your.package.name with your base packege name.
    PackageInfo appPkgInfo = getPackageManager().getPackageInfo("your.package.name", PackageManager.GET_SIGNATURES);


    for (Signature signature : appPkgInfo.signatures) {

        MessageDigest messageDigest = MessageDigest.getInstance("SHA");
                md.update(signature.toByteArray());

        // See Logcat for your hash key and put in on Facebook developer console.
        Log.d("Your Hash key", Base64.encodeToString(messageDigest.digest(), Base64.DEFAULT));
    }
    } catch (NameNotFoundException e) {

    Log.e("ERROR",e.getMessage());

    } catch (NoSuchAlgorithmException e) {

    Log.e("ERROR",e.getMessage());

}

答案 1 :(得分:0)

这是通过从签署我的apk后生成的密钥库生成hashkey来解决的。

我使用this这个答案从keystore生成hashkey。谢谢他:)