[SOLVED] Facebook working until signed version then hash doesn't match :(
I'm working on a new game (same as everyone else), I've integrated Facebook following their guidlines, my app when I build it and send it to my phone works fine, I exported a signed version to upload to google play and put the same version on my phone, now I can't log in on the phone as I get a facebook 'invalid hash key' does not match stored hashes' error message.
Is this just because its a signed version put on my phone and everything is actually fine or is this because I did something wrong signing the package or something else?
Thanks in advance :)
Diego
[SOLVED UPDATE] I needed to generate a key in unity and save it tutorial here : https://www.youtube.com/watch?v=iBmgCnJ_z1k&feature=youtu.be
Then use terminal on my mac and run the following command : keytool -exportcert -alias -keystore | openssl sha1 -binary | openssl base64
Swapping my release key alias and path for the name of the user in the keystore and the path to the file where I stored my keychain
If you get a syntax | error, don't use <> brackets when entering the username and path to the file.
I then copied the hash from terminal and pasted it into the facebook dev console.
Then finally I ran my app go the same error but a different hash, I copied that off my phone and pasted that into facebook dev console (so there are now 3, the debug one from fb sdk in unity, the generated one by terminal and the one from my phone). Done. for now....
Onwards and upwards to the next hurdle....
Answer by Niks4Linux · May 19, 2016 at 12:01 PM
How did you created your hash? Did you use the hash from the Facebook Settings in the Editor or you created your own hash from command prompt? I had the same problem but, I have created my own hash from command prompt using this step by step tutorial to create hash (15 steps are given) -
http://stackoverflow.com/questions/5306009/facebook-android-generate-key-hash
Try this tutorial and use that hash and upload the build. Maybe this will solve your issue. It worked for me.
Answer by diegomh7 · May 19, 2016 at 12:20 PM
I used the editor in unity then copy and pasted it to the facebook app as per their guidelines. It works perfectly fine until I sign the exported apk file and then the same package transfers to my phone and boom, facebook shows a hash mismatch warning message.
Can you try using command prompt to create Hash $$anonymous$$ey? And then try it with your app in both signed and unsigned version or you can copy and paste the same mismatched key into your Facebook app setting and then try. And also check your package name, class name is correct in the app setting. Hope it helps! :)
I manually added the key shown on my mobile to facebook and still get the same issue, it's wierd how after signing the apk in unity then exporting the hash should change?? I'll try the ter$$anonymous$$al way now and get back to you,
cheers btw
I've tried using open ssl in ter$$anonymous$$al and just get errors, I've looked for tutorials online but I always end up at android developer pages and the content isnt right for my unity project. God knows what I'm doing wrong
I must be doing something wrong when signing the product to cause the hash key to have a mismatch, even if I copy and paste the hash code from my android phone and write it into facebook dev console it still errors when I load the app and try to login, I need some kind of step by step creation of the key and copy that to facebook app dev page, Im using a mac to access openssl if that's any difference.
This will apparently be the solution:
https://developers.facebook.com/docs/android/getting-started#create_hash
Followed by :
https://developers.facebook.com/docs/android/getting-started#release-key-hash