Friday, 7 March 2014

Android Unity Facebook Deployed Login Now Working! :)


No doubt some of you will be trying to integrate the Unity Facebook SDK into your unity projects that you wish to deploy to Android devices.

If you followed the facebook docs guides, you probably have it working in the Unity3D editor.  You can Login, and make API calls etc..

This post covers the problem when you deploy to Android, and the Login doesn't appear to work.  You may have received the following error:  "Invalid android_key parameter, The key 'hjd7hf...' does not match any allowed key . Configure your app key hashes at..."

The reason for this error is that your APK is signed with the debug hash key in unity.


NB. This post assumes you have installed the JDK, and ADT required to build android apps, and therefore, android games for unity.

disclaimer: I tried this a few times to figure it out so the steps below may not be optimal

Follow the below steps and you will be able to Login to Facebook within your Android deployed Unity game:

1) In Unity, go to File -> Build Settings... -> Player Settings.

2) Click on Publisher Settings,  Under Keystore, with 'Use Existing keystore' checked, click on 'Browse Keystore'.

3) Browse to C:\Users\[YOUR USER ACCOUNT]\.android\debug.keystore

4) Now, under the heading 'Key', click on the Alias drop down, and click 'Create a new key', and fill in all the fields you need. The password should be 'android'

5) Under build settings click 'Build'

6) Now, under publishing settings, click on 'Create New Keystore'

7) Now build your project again. The build should now be signed with the correct hash key.

8) In order to view your hash key, start a command prompt and run the following (replacing YOUR USER ACCOUNT):

keytool -exportcert -alias androiddebugkey -keystore "C:\Users\[YOUR USER ACCOUNT]\.android\debug.keystore" | openssl sha1 -binary | openssl base64

the password will again be 'android'

9) Now copy this to your Facebook dev settings

10) If you deploy to an android device, this should now work :)

Please let me know if you encounter any further problems, or if my instructions are incorrect at any step


Lee Allan

No comments:

Post a comment