30

When I try to implement Facebook Connect in my Android application, I get the following error.

11-02 16:41:31.660: D/Facebook-authorize(13194): Login failed: invalid_key:Android key mismatch. Your key "8Ioc4p/jMXoU9Lezug4nzmZfFUg" does not match the allowed keys specified in your application settings. Check your application settings at http://www.facebook.com/developers

I reset the key in the Facebook App and still it shows the same error. How can I fix it?

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Harsha M V
  • 54,075
  • 125
  • 354
  • 529
  • 1
    I noticed in my AndroidManifest.xml, I had: android:launchMode="singleInstance" I never got the key invalid error. But when I removed that line, I started getting the key invalid error. I don't know how or is it related to this error. – Lisa May 03 '12 at 13:41
  • @Harsha M V. my hash key is **YLMxxxxxxxxxxxxxxxR8=** which i get in the command prompt. but the error is same as yours saying **YLMxxxxxxxxxxxxxR8** does not match the allowed keys. So should i remove **=** from the hash key in the configurations?? Because the accepted answer below shows an **=**. How did you solve it? Thank You – Archie.bpgc Oct 24 '12 at 13:48

10 Answers10

65

Your key is: "8Ioc4p/jMXoU9Lezug4nzmZfFUg"

Now copy this key and open this URL, and paste this key in the native Android app, marked with a green border.

Enter image description here

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
  • hey buddy if u open so many threads they will down vote u :P use the Edit Button to edit ur answers.. on the same one. and thanks a lot :) i will ping u directly if i need some help hope its fine – Harsha M V Nov 03 '11 at 08:33
  • 6
    so that `=` is extra or no need to add there ? – Chintan Khetiya May 14 '13 at 12:26
  • I'm having this issue now too with facebook connect, and I've checked so many times that the keys do match and I'm using the right app_id and everything, I am but I still can't get it to work. – CaffeinatedCM Jun 23 '13 at 00:19
  • That is what is called "The address is on the wall" :) – Ivan Chernykh Nov 26 '15 at 10:27
  • @user647826 Can you please tell me why Facebook showing this error ? Facebook showing different key has and I got the different released key hash from command prompt. How can i achieve this hash key before make the app live ? What would be the proper solution for this for future apps – Nooruddin Lakhani Jul 06 '17 at 12:09
11

I dont know if your problem is resolved right now but I was having the same problem as you and now I find the complete solution.

You have two enviroments for the development: debug and a signed application, when you use this commands to get your key

keytool -exportcert -alias androiddebugkey -keystore ~/.android/debug.keystore | openssl sha1 -binary | openssl base64 you are getting the key for the debug.keystore,

But when you sign the app you get a new key because your app is using a new keystore.You can get your "sign app key" using this program. http://www.easyfacebookandroidsdk.com/download/keyhash.zip but you have to sign with the same keystore that you are using in your app.

Chintan Khetiya
  • 15,962
  • 9
  • 47
  • 85
Leonardo Arango Baena
  • 870
  • 1
  • 10
  • 15
  • +1 thx - for some reason the command line solution of `keytool -exportcert -alias androiddebugkey -keystore ~/.android/debug.keystore | openssl sha1 -binary | openssl base64` didnt work for me as it was giving a differnt hash (and my project is using that location to find the debug keystore) but the easy facebook SDK mentioned in this comment worked! Saying that the generated hash was a few chars differnt from the one reported in the app on error ( + to -, _ to /) - which is weird. – Dori Aug 30 '13 at 08:27
  • I am having the same problem where my app's signature does not match what the FB directions for keytool outputs. Anyone have any idea why this is? – swooby Feb 17 '15 at 19:28
  • 1
    What do I do with that zip file? – Katedral Pillon Mar 19 '15 at 00:23
5

Your key is

8Ioc4p/jMXoU9Lezug4nzmZfFUg

This key is encrypted by your device so you have we have to let this key be known to Facebook user (in your application which you create in Facebook).

Now you have to copy this key in the native app and then save it. After some minutes, you can get all access..

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
4

The error for me was caused by the mismatch between my debugging key when I was testing my app and the release key when I was signing a release version.

11-02 16:41:31.660: D/Facebook-authorize(13194): Login failed: invalid_key:Android key mismatch. Your key "8Ioc4p/jMXoU9Lezug4nzmZfFUg" does not match the allowed keys specified in your application settings. Check your application settings at http://www.facebook.com/developers

If you copy and paste 8Ioc4p/jMXoU9Lezug4nzmZfFUg to the Android Key Hash field in the Facebook application settings it should work. If you get this error again (showing a different key value) when you test your signed release version, copy that additional key into the Hash Field after the original entry, so you have two values in there.

I was surprised that more than one entry was allowed in the Key Hash Field, but it appears it is ok and it's solved the problem for me for both testing and release versions.

brandall
  • 6,094
  • 4
  • 49
  • 103
  • I voted this up only because the solution worked for me -- pasting the error message's key hash into my FB app settings "Key Hashes" field. – Pup Jul 24 '15 at 19:08
2

The debug native Android application key is generated automatically using debug.keystore file located at ~/.android/debug.keystore. When you are developing your application on multiple machines, you should have the same debug.keystore file...

Once this is done, you can paste the debug native Android application key to the Facebook settings page of your application.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
ashvayka
  • 21
  • 1
2

You actually do not past this key directly, but a Base64 value of this key.

Refer to https://developers.facebook.com/docs/mobile/android/build/#sig which explains you how to generate this.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Deepak G M
  • 1,650
  • 17
  • 12
1

Please check your application page in Facebook and confirm that both keys are same. I think you won't register your app on Facebook

Kiran Babu
  • 1,893
  • 2
  • 13
  • 7
1

You can use Facebook application in your application so you use this. In that source code for Facebook integration is there.

1

If the key is invalid, then you have to create the new Facebook application on the Facebook developers site. It provides you with a new key. Use that key in your Facebook demo.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
dilipkaklotar
  • 1,469
  • 3
  • 20
  • 28
0

I have this problem, I solved it by deleting "C:\Users\user_name.android\debug.keystore" and generating a new one with eclipse. Then I change the old hash key from Facebook and it works!