Facebook.init() function causing null exception

Background:
I am trying to integrate facebook for a unity-android project and I can’t seem to make it working, I have looked on the fb page and allot of other place but can’t seem to find a what I am doing wrong.

Problem:
When trying FB.Login i get the reference exception: Facebook object is not loaded. Did you call FB.init?

Code for InitializeFB.cs

using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using Facebook.MiniJSON;
using System;

public class ConncetToFaceBook : MonoBehaviour {

// Connect to facebook
void Awake () {
	// Required
	DontDestroyOnLoad(gameObject);
	
	// Initialize FB SDK
	enabled = false;
	FB.Init(onInitComplete, OnHideUnity);

	//Display id
	Debug.Log (FB.UserId);

	//Login to facebook
	FB.Login("email,publish_actions", LoginCallback);
}

/* Helper Methods */
private void onInitComplete ()
{	
	enabled = true; // "enabled" is a property inherited from MonoBehaviour
	if (FB.IsLoggedIn) 
	{
		//Some Code            
	}
}

private void OnHideUnity(bool isGameShown)
{

	//some code
}

void LoginCallback(FBResult result)                                                        
{                                                                                          
	if (FB.IsLoggedIn)                                                                     
	{                                                                                      
		OnLoggedIn();                                                                      
	}                                                                                      
}                                                                                          

void OnLoggedIn()                                                                          
{                                                                                          
	Debug.Log("Logged in. ID: " + FB.UserId);                                            
} 

}

Code for FB.init

public static void Init(
        InitDelegate onInitComplete,
		string appId = "{My app ID}", //I did put my own here. Plus I use " instead of ' because ' give me a error. 
        bool cookie = true,
        bool logging = true,
        bool status = true,
        bool xfbml = true,
        bool frictionlessRequests = true,
        HideUnityDelegate onHideUnity = null,
        string authResponse = null)

A few things that come to mind:

  1. Why are you setting the monobehaviour’s enabled to false?
  2. FB.Init is an asynchronous operation. It does not complete immediately, that is why you need to pass it a handler that will execute when it’s done. Until it completes you should be using the FB object or call Login on it, since FB did not finish initializing everything it needs.

Move the code that does the login to the onInitComplete callback, that is how we do it in our project exactly.