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
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.
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 SDK 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.
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 JDK installed (32 & 64bit).
Thank you so much, solved my problem in no time!
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 "Keytool not found" is showing. What am i doing wrong? can someone please guide me
If you have the 32 bit version of the JDK installed your path is "C:\Program Files (x86)\Java\jdk1.7.0_45\bin\".
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 -.-
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.
Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.
The best place to ask and answer questions about development with Unity.
To help users navigate the site we have posted a site navigation guide.
If you are a new user to Unity Answers, check out our FAQ for more information.
Make sure to check out our Knowledge Base for commonly asked Unity questions.
If you are a moderator, see our Moderator Guidelines page.
We are making improvements to UA, see the list of changes.
Answers and Comments
29 People are following this question.
Unity Facebook SDK - Android Deployement - Key Hash ?
Export & Install APK on Android
is there a way to link .NET dll base on platform?
Android: ScreenResolution/Scaling Script
Trouble with Android Build?