Debug Android Hash Key - Facebook SDK

NOTE for 5/2014 …

the only real solution to this problem is the “Rafael solution” here:

it’s also the ONLY solution if you’re on Mac. Hope it helps


Hey Guys,

I am having difficulty in getting the FriendSmash example to login on an android device and I believe it has to do with my inability to get unity to recognise the Debug Android Hash Key for the Facebook SDK.

I am using Unity 4.2.2, Facebook Unity SDK 4.3.4, JDK1.7.0_04, Android SDK 22.3 and have OpenSSL.exe (0.9.8h-1) located in the bin directory of the JDK.

However the Debug Android Hash Key under Facebook>Edit Settings is blank.
According to this Unity attempts to run:

keytool -exportcert -alias androiddebugkey -keystore %HOMEPATH%\.android\debug.keystore | openssl sha1 -binary | openssl base64

If I enter this as is into cmd when in the JDK/bin directory (where the keytool is - by the way, how does unity know to go to this directory?) then it asks for a password and gives me the key which I have entered into the fb developer app page. However Unity still does not recognise this in Facebook>Edit Settings and this remains blank.

I am sure I have set everything else up right (in terms of bundle identifiers, app id etc) and that this must be my problem, the only other things I can think of is that FB.GetAuthResponse does not exist in the project which I replaced with FB.Login.
The app builds and runs fine on my device - I just cannot login to facebook.

I have seen a few others experience difficulty, however the fixes have not worked.

Any Ideas.

Thanks,

Here’s instructions for @allesisda and anyone else who might be having trouble with this on Windows. @Michieal’s instructions are correct, but I found them a bit hard to understand.

Download and install OpenSSL.

Add the OpenSSL directory to your path.

  • Go to: Control Panel > System > Advanced system settings > Environment Variables
  • Select the Variable “Path” in the “System variables” window and click Edit.
  • Add the path to your OpenSSL bin folder to the end of the “Variable value” text. e.g. I added ;C:\Program Files\OpenSSL-Win64\bin to the end of the value text.

Restart Unity3D.

If you get the error in FacebookSettings “Keytool not found”, you need to add the JDK (Java Development Kit) bin directory to the Path variable value.

  • Follow the same steps as before, but instead of the OpenSSL bin path, add the JDK bin path. e.g. I added ;C:\Program Files\Java\jdk1.7.0_45\bin to the end of the value text.

Downloads - Unity SDK - Documentation - Meta for Developers Has the newest version of the Facebook SDK.
If you don’t already have the OpenSSL files, download it and install it in (copy it into) your path. With 4.3.6 of the SDK it automatically tells you that it is missing (if it is) and will create the Hash for you. I did it the hard way (above) to get the hash key, and I was still having login issues, so I went and checked, downloaded the 4.3.6 version of the SDK (I’m using Unity 4.3.0f) and added the directory (openssl\bin) to my path (in the environment variables in the Windows Computer Properties->Advanced System Setting->Environment Variables) and viola! it did it automatically and shows the Hash Key, just like the video says it should! :smiley:

Good luck & Happy Coding!!

I used following steps to generate a Key Hash for my app in facebook: (I am using Mac OSX 10.12.6

First open a terminal (open a command prompt in windows).
Navigate in the terminal to the directory where your Android debug.keystore is stored.
Mostly it will located under “/Users/user_name/.android/” (In Windows will be C:\Documents and Settings.android).
Once you are in the “.android” directory, run the following command.

keytool -exportcert -alias androiddebugkey -keystore debug.keystore | openssl sha1 -binary | openssl base64

When it prompts you for a password, type android and hit Enter

Copy the value printed in the terminal that ends with an “=” and paste it in the Key Hash field in Facebook. Then click the Save Changes button.

this video will help you to solve your question

This happens often when you update your Java and the folder name changes, meaning your PATH Enviorment variable is directing towards a folder which doesn’t exist (anymore). Update your path.