Unity Facebook SDK - Android Deployement -

Hi everyone, hope I m not in the wrong spot of the forum for this thread !
Any ways, I got an issue to set up the latest version of the Unity Facebook SDK released, the 4.2.1
(build version 130912.80d74183e6e5bd9)

The problem that I m blocked at the app config step, following the documentation on facebook developer pages, it says that the SDK should be printing up the Key Hash for my app so I just have to copy / paste it the the facebook app config edition. But actually the Facebook Settings tool in Unity doesn’t show up any key hash (nothing appears in front of Debug Android Key Hash), the app name and app ID are there, as much as the package and class name !

I have a feeling that I m missing something stupid out there but after 3 hours trying to find any hint somewhere, … I m just stucked.

Any help please ?

same problem for me!

same problem on FacebookSDK-130826.unitypackage

I dont know If I should be happy to see that I m not the only one in this case or be sad because we are still stuck

I’m also having the same issue with FacebookSDK-130912.unitypackage and seem to be stucked there. I managed to get the hash keys out using keytool (as found in http://javatechig.com/android/how-to-get-key-hashes-for-android-facebook-app/ ), registered them to Facebook and made sure that Unity is using those keys, but that hasn’t helped at all and the problem persist in the way described.

Hi guys it seems that unity3d facebook sdk for windows has a bug to fixed this problem follow instructions in this link below
http://blog.yoz.sk/2013/02/quick-tipkey-hash-for-facebook-android-application-in-air/

smile! :smile:

That trick truly works, got it talk with FB now once entering the hash in FB, thanks a million!

Hi everybody ! Glad to see that some of you could resolve their problem with the link provided by swifer07 so we thank him a lot :slight_smile:

But on my side I kept working on trying to make things more clear and specially after the release of the new FBUnity SDK 4.2.4 so here is what I came up with :

Download Openssl, extract the archive, put the content of bin folder in C:\Program Files\Java\jdk1.7.0_06\bin (or your Java SDK Folder) and execute the following command in Command Prompt (cmd) :

keytool -exportcert -alias androiddebugkey -keystore %HOMEPATH%.android\debug.keystore | “C:\Program Files\Java\jdk1.7.0_06\bin\openssl.exe” sha1 -binary | “C:\Program Files\Java\jdk1.7.0_06\bin\openssl.exe” base64

Of course please think about replacing : *C:\Program Files\Java\jdk1.7.0_06* with you local JDK installation folder path

Important To know also, the right version of openssl tu use on windows 7 x64 with JDK version jdk1.7.0_40 (that’s actually my config) is the version 0.9.8h-1 that you can download in zip format right here

Now to make things clear and easy to understand, you can implement by yourself the SDK in the way that makes it clear for you (skip the example provided within the package you get from the Assets Store).

First thing to do is make sure that you configured your application on facebook and on unity in the right way Facebook Web Games - Unity SDK - Documentation - Meta for Developers

Then just create a new scene, create a single new script where you write down this (after you made sure that you did read it to understand it)

using UnityEngine;
using System.Collections;
using Facebook;        // Must be specified to use HTTpMethod class

public class InitAndLoginToFB : MonoBehaviour
{

    bool isEnabled;
    bool isLogged;
    string userId;

    Texture pic;

    void Awake()
    {
        isEnabled = false;
        isLogged = false;
        userId = "not received";
    }

    private void SetInitFB()
    {
        // This method method will be called withing the callback received by FB.Init()
        isEnabled = true;
    }

    private void SetAvailability(bool a_status)
    {
        // This method method will be called withing the callback received each time Unity gets or looses Focus (True/false)
    }

    void LoginCallBack(FBResult result)
    {
        if (result.Error != null)
        {
            Debug.Log("Receive callback login error :: " + result.Error.ToString());
        }
        else
        {
            if (FB.IsLoggedIn)
            {
                // Case login was successful 
                isLogged = true;
                userId = FB.UserId;

            }
            else
            {
                // Case login failed (because of cancelling for example)
                isLogged = false;
            }
        }
    }

    void GetProfilePicAnswer(FBResult response)
    {
        // This method method will be called withing the callback received by FB.API()
        // You can add a control here for any kind of failure to print up a default picture for example
        if (response.Texture != null)
        {
            pic = response.Texture;
        }
    }

    void Start()
    {
        // Must call FB.Init Once
        FB.Init(SetInitFB, SetAvailability);
    }

    void OnGUI()
    {
        if (isEnabled)
        {
            if (!isLogged)
            {
                if (GUI.Button(new Rect(5, 5, 100, 40), "Login FB"))
                {
                    // In the string you are sending within the login process you can specify wich "permissions" you are asking for (in this case only to get the user's email)
                    FB.Login("email", LoginCallBack);
                }
            }
            else
            {
                GUI.Label(new Rect(120, 5, 200, 40), userId);
                if (GUI.Button(new Rect(5, 5, 100, 40), "GetPic"))
                {
                    FB.API("/me/picture", HttpMethod.GET, GetProfilePicAnswer);
                }
            }

            if (pic != null)
            {
                GUI.DrawTexture(new Rect((Screen.width - pic.width) / 2, (Screen.height - pic.height) / 2, pic.width, pic.height), pic);
            }
        }
    }
}

I am using the FB SDK to use it with a android game and I keep getting a message saying "unfortunately the app has stopped " when trying to login to facebook from the game.

Any ideas?

Same thing here. It seems that there is no way to make the facebook SDK work with android. And the fact the the official android tutorial video (https://www.youtube.com/watch?v=5g0WdYbq-dg#t=705) “skips” the part where it should show the demo in an actual Android device due to “not being set up to make a screen cast from an Android phone” that says it all.

Hi, I just made a thread about this.
The windows version is broken, even after I managed to print the hash by modifying the editor it didn’t work.
Here is how to fix it :
http://forum.unity3d.com/threads/222977-How-to-fix-Facebook-SDK-Android-Login

Regarding the crash, I only tested their demos, maybe it’s a compatibility issue with some JDK? It didn’t work with my 64bit Java, now I’m using the latest 32 bit JDK with Android SDK 4.4

DaMex, cheers for that! Was bugging me for a while.

Hello, i have the same problem

but, in the command for CMD: %HOMEPATH% = ?

%HOMEPATH% is path of the archive .apk?

which file should go this route?

Hi all. Haven’t read all of the answers, but encountered the same problem.
I used the answer from the user vfxjex from this post which i think is a good solution. It worked very well.

I have the same problem. Strange thing is the application worked fine before using the facebook sdk 7.4.0 with the environment variables linked for java and openssl in path.