- Home /
Debug Android Hash Key - Facebook SDK
NOTE for 5/2014 ...
the only real solution to this problem is the "Rafael solution" here:
http://answers.unity3d.com/questions/609810/using-facebook-api-with-android-says-login-is-canc.html
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,
Did you found a way around it? Because I'm experiencing the same problem.
Hey gajdot - the answer is.. kind of. I have not managed to get Unity to recognize the hash key. However I just loaded the app up again then after reading your comment and it is working!? For your sake all I have done is run the above keytool command copied the key into facebook app (also ensuring app id and bundle id are right) and that's it. Now I have not done anything since posting this question and it did not work then I swear it - and Unity still has the blank line at hash key so guessing its not a requirement. Happy to try help further but I really don't know why it wasn't working a few days ago and is now. Have left question unanswered as still unsure why Unity will not recognize the key.
I've not gotten the hash key to show up either. I'm using Unity 4.3 & FB SD$$anonymous$$ 4.3.4... I was able to get the hash key out of the keystore using the keytool application. Thus far, my droid app is not connecting to Facebook :( fully, but I am hoping that is an issue on my side and not a hash key issue. If anyone has anything to add to this, it would be greatly appreciated. FYI - to publish your application onto Google Play, you cannot use a debug key... at all.
Well i had to revert to 4.2.2 unity project and there it works fine(the hash key won't show up, but at least when I generate it, it will accept it) and I can connect to Facebook.
Answer by hamstar · Mar 03, 2014 at 09:15 AM
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.
Win32 OpenSSL v#.#.# (not Light)
OR Win64 OpenSSL v#.#.# (not Light)
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.
p.s. I also found that to build I had to have both versions of JD$$anonymous$$ installed (32 & 64bit).
Love you Hamstar, you make my day! I spend 3 days with this problem and now thanks to you its finally working. And sorry for my english.
i've done this but again the error "$$anonymous$$eytool not found" is showing. What am i doing wrong? can someone please guide me
If you have the 32 bit version of the JD$$anonymous$$ installed your path is "C:\Program Files (x86)\Java\jdk1.7.0_45\bin\".
Answer by muhammadtahiriqbal · Jan 11, 2018 at 06:15 AM
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.
Answer by MichiealO · Nov 29, 2013 at 07:57 AM
https://developers.facebook.com/docs/unity/downloads/?campaign_id=282184128580929&placement=SDK_list 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! :D
Good luck & Happy Coding!!
copy it into wich path? the unity asset folder? should the properties->Advanced System Setting->Environment Variables be in unity?
and where am i supposed to type in the "keytool command?" cmd says that keytool is a unknown command -.-
@allesisda the path that you put it into is your computer's PATH variable. Then, you open up a command prompt and type things in there. Sorry for the length of time on my response... I honestly had forgotten all about this answer... >.>
Answer by JigneshKoradiya · Aug 02, 2015 at 04:55 PM
this video will help you to solve your question
Answer by Zewde · Dec 20, 2015 at 11:20 AM
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.
Your answer
Follow this Question
Related Questions
Unity Facebook SDK - Android Deployement - Key Hash ? 9 Answers
How can i make Android Textures rendered better? 1 Answer
Color Correction Effect on Android, Unity 4.3 1 Answer
[EGL] Failed to create surface :: GfxDevice is in invalid state 0 Answers
Permissions not being granted with Facebook App installed 0 Answers