I just spent the whole day trying to understand how make the facebook sdk works on my Android device.
So here is the solution for anybody in my same shoes:
Avoid the user generated key hash, it doesn’t work( at least for me and probably many other). Anyway it’s made just for debugging and it’s not explained how to use for release.
To generate the hash use this on Windows.
And this on Mac:
It will ask the password for the keystore, if you don’t know yours just create a new keystore.
The path after -keystore is the keystore you want to use, and the word after -alias is your release key, so you can use the same method when publishing.
Copy the hash that it will give you in the facebook app settings and you are done.
More details here(the facebook unity sdk guide is totally useless):
Adding c: was what I did in the editor script to make it work, but on the commandline I didn’t have that issue on Windows 7.
Are you sure the password you are using is correct? Did you try regenerating the debug.keystore from unity?
On the player settings where you can set android specific settings like icons, there are two buttons, Use existing keystore, and create new keystore.
Try creating a new one, I didn’t test with the existing one, it could be the password isn’t really android.
Tried using both C:%HOMEPATH%.android\debug.keystore and a new one.
On a samsung galaxy (with facebook app installed) after clicking login, it ask for permissions (faceboook_test wants to access bla bla). Clicked ok, it return to the app page with login false.
On a Android 4.2.2 emulator (without facebook app installed) clicking on login crashes the app.
UPDATE: it seems that there is a weird error in the permission dialog: even if i press “OK” it comes back as cancel was pressed (in the log it appears: “login cancelled by player”).
I had the same issue until I properly configured it. Login cancelled by user is because of the hash.
Did you copy the hash generated by the command in the facebook app settings?
I generated a new one and overwritten the existing one at the HOMEPATH location using android as password, then generated the hash with the command line and copied it in the facebook dev center.
Battling with the same issue i think.
Did you notice that things work differently depending on whether you have the native android Facebook app (“FB app” from now on) installed on your device (or maybe that’s common knowledge but just not mentioned on this thread )? For me the login works if i don’t have the native FB app installed.
Maybe that’s the problem “newlife” is having too.
I have an old, already released app, into which i’m trying to implement FB login. I regenerated the hash with my “release” keystore and openssl.
The problem is that I can’t perform the “first time flow” if I have the native FB app installed. Everything works perfectly if I log into my game without the FB app installed for the first time (so that FB SDK brings up the browser for logging in, instead of the FB app). After one successful login, I can install the FB app on my device and still my game continues to log in without problems.
With the native FB app login screen, my game doesn’t seem to be able to get the permissions right.
I guess i gotta try to regenerate the hashes again in case i made a mistake or something. Otherwise this is getting really frustrating.
OK so the hashes surely aren’t the problem for me.
In Eclipse’s LogCat i’m able to see the calls and if I intentionally screw up the login call, i can clearly see the error messages now.
With my original code the login call goes through ok but it just doesn’t seem to return the FBid and FB.isLoggedIn stays false
here’s the LogCat of the reply i get
sending to Unity OnLoginComplete({“key_hash”:“n0RW5G6…8HF8AjM8=\n”,“access_token”:“CAAG3N…jxzwZDZD”,“opened”:true})
even though the reply seems to contain the access_token, the FB.accessToken stays empty
Second: In class FacebookAndroidUtil.cs , line 62, you add System.Environment.GetEnvironmentVariable(“HOMEDRIVE”) before System.Environment.GetEnvironmentVariable(“HOMEPATH”). Facebook SDK requires a file debug.keystore in : C:\Users\UserName.android\debug.keystore.
If the Unity Editor, Edit Setting Facebook has yet to create android debug hash key. Then use the Eclipse Software, create and run onr any project. Eclipse will generate a debug.keystore. If it is’t create in folfer : C:\Users\UserName.android\debug.keystore , then find it, coppy and paste into C:\Users\UserName.android\debug.keystore
Third: publish your app in Facebook, so be sure it is:“This app is public and available to all users”.
No I didn’t. I still cannot log in. On Windows it works nice. It asks for token and then I can see friends and co… but on my android device cannot login. I just get “Cancelled by Player” something like that.
I have a platfomr there. I put package name, class name, key hash too. Everything took from unity editor. But doesn’t work
1 . Get the fingerprint SHA1 (keytool -printcert -file CERT.RSA)
2 . Copy the SHA1 HEX and convert that code to Base 64 (Hex to base64 converter)
3 . You should copy the fingerprint in base 64 in the Android key hashes on your facebook app configuration.