1

I have generated the key hash for login with facebook by this method.

 public void printHashKey() {
    try {
        showLog("PackageName " + getPackageName());
        PackageInfo info = getPackageManager().getPackageInfo(getPackageName(), PackageManager.GET_SIGNATURES);
        for (Signature signature : info.signatures) {
            MessageDigest md = MessageDigest.getInstance("SHA");
            md.update(signature.toByteArray());
            String hashKey = new String(Base64.encode(md.digest(), 0));
            showLog("printHashKey() Hash Key: " + hashKey);
        }
    } catch (NoSuchAlgorithmException e) {
        showLog("Error in printHashKey()" + e);
    } catch (Exception e) {
        showLog("Error in printHashKey()" + e);
    }
}    

When I have generated a signed apk , then it said the key hash generated by above method at runtime can be used and it doesn't match with the hash registered at the Facebook developer console. But it was OK as I have tested with it multiple times before generating a debug signed apk. So I have generated another key hash by using this

keytool -exportcert -alias androiddebugkey -keystore C:\Users\USER\Documents\keys\ws_key.jks | C:\OpenSSL\bin\openssl sha1 -binary | C:\OpenSSL\bin\openssl base64

Again, the generated key is not allowed to login with facebook.

So I have generated the key hash by generating SHA1 key with the generated app and then converted the generated SHA1 key to hash.

Then the problem has solved. I know the release apk and debug apk have the different signature and different hashes. My question is - "Why the key hashes are different even though the app is still in debug mode?"

Daniel Jr McCoy
  • 157
  • 1
  • 15

0 Answers0