I know its very old and there are many questions with similar problem. I have already seen different answers for it but still the problem is coming in my application.
I am working on Facebook login in app. Before uploading to Google Play it is working perfectly locally. But after publishing on Google Play, it is giving an error of INVALID KEY HASH.
I have generated a key hash on Android Studio using the code given below and saved it on the Facebook Developer Console. In the Facebook Developer Console, I have also put the key hash which comes on the Error message on the App but still it is giving me the same error.
PackageInfo info;
try {
info = getPackageManager().getPackageInfo("i.am.peace.by.murgency", 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 (PackageManager.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());
}
Through terminal with this statement:
keytool -exportcert -alias androiddebugkey -keystore ~/.android/debug.keystore | openssl sha1 -binary | openssl base64