Android Facebook integration with invalid key hash Android Facebook integration with invalid key hash android android

Android Facebook integration with invalid key hash


The generated hash key is wrong. You may get the hash key using two steps.

One is through a command prompt. Another one is through coding. The hash key through a command prompt is working on the first time only. I don't know the reason. I have also got the same problem. So I tried it through programmatically.

Follow these steps:

Paste the following code in oncreate().

try {    PackageInfo info = getPackageManager().getPackageInfo(                           "com.example.packagename",                           PackageManager.GET_SIGNATURES);    for (Signature signature : info.signatures) {        MessageDigest md = MessageDigest.getInstance("SHA");        md.update(signature.toByteArray());        Log.d("KeyHash:", Base64.encodeToString(md.digest(), Base64.DEFAULT));    }}catch (NameNotFoundException e) {}catch (NoSuchAlgorithmException e) {}

Modify "com.example.packagename" with your package name in the above coding without fail (you may find your package name in the Android manifest file).

Run your application. Go to the activity where you pasted the above code. In the LogCat file, search for "KeyHash". You may find a key hash. Copy the key hash and go to Facebook application dashboard page. Go to settings and enter the details like in the below image.

Enter image description here

Once you finished the above step, relaunch the app again. You may now log into Facebook.For more details about key hash, check the link.

If you add wrong information in the settings page, it means it will give some error. So use the correct information there. And also if the public (other than you) need to use your application means you need to enable the permission (change "yes" in the "Status & Review" next to the setting).


If you are using Google Play App signing:

Open the App signing section in Google Play Console, and get the SHA-1 hash under App signing certificate. Then convert it to Base64, for example with this tool: Hexadecimal -> base64 string decoder

Console screenshot

Convert to Base64 screenshot


If you are facing this problem then put this key into your developer.facebook.com:

Enter image description here

Then make sure your app is live on developer.facebook.com.

This green circle is indicating the app is live:

Enter image description here

If it is not then follow these two steps for make your app live:

Step 1 Go to your application→setting→ add Contact Email and apply Save Changes.

Step 2 Go to the App Review option and make sure this toggle is Yes. I added a screenshot:

Enter image description here

Note: If you want to copy the hashkey, check the BlueServiceQueue in LogCat.