Reputation: 501
I've created an app which uses the facebook login. I've added the key hash to the facebook developer page and it worked fine in all devices. Now I've uploaded the app to google play, and when I try to login, it sais that the key hash does not match any stored key hashes. I copied the key hash in the error message and pasted it. Still - doesn't work. I tried to generate a key hash in cmd using the release key store - no luck.
Does anyone know what is the problem and how to fix it?
Thanks in advance!
Upvotes: 0
Views: 597
Reputation: 10971
Try adding the following code snippet to your app while it's signed with the release certificate, compare the hash output with the one you submitted to the Facebook portal:
PackageInfo info;
try {
info = getPackageManager().getPackageInfo("com.package.name", PackageManager.GET_SIGNATURES);
for (Signature signature : info.signatures) {
MessageDigest md;
md = MessageDigest.getInstance("SHA");
md.update(signature.toByteArray());
String hash= new String(Base64.encode(md.digest(), 0));
Log.e("hash", hash);
}
} 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());
}
Upvotes: 2