Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Facebook SDK assembly cannot be loaded

Discussion in 'UGUI & TextMesh Pro' started by ImpossibleRobert, Aug 23, 2014.

  1. ImpossibleRobert

    ImpossibleRobert

    Joined:
    Oct 10, 2013
    Posts:
    521
    After updating to Unity 4.6 the Facebook SDK is not working anymore due to assembly authorization errors, see below. Does anybody know how to get this running again?

    Code (CSharp):
    1. Unable to verify assembly data; you must provide an authorization key when loading this assembly.
    2. UnityEngine.Security:LoadAndVerifyAssembly(Byte[])
    3. <LoadFacebookClass>c__Iterator12:MoveNext() (at Assets/Facebook/Scripts/FB.cs:422)
    4.  
    5. Could not securely load assembly from https://integrated-plugin-canvas-rsrc.fbsbx.com/rsrc/unity/lib/sdk_6.0/CanvasFacebook.dll
    6. UnityEngine.Debug:LogError(Object)
    7. FbDebug:Error(String)
    8. <LoadFacebookClass>c__Iterator12:MoveNext() (at Assets/Facebook/Scripts/FB.cs:426)
     
  2. Tim-C

    Tim-C

    Unity Technologies

    Joined:
    Feb 6, 2010
    Posts:
    2,221
    can you raise a bug about this, it seems like something needs to be updated by us or facebook.
     
  3. Kiwasi

    Kiwasi

    Joined:
    Dec 5, 2013
    Posts:
    16,860
    Its a pretty easy fix. The Facebook SDK runs a check to see if its in Unity 4.5, as 4.5 introduced new security features for loading assemblies. If you remove the pre-processor directive for compiling in 4.5 then it works fine. I suppose you could also change it to #if Unity_4_6. But that will break again next time you upgrade.

    Edit: Tried to post the solution here but haven't yet got the hang of formatting code on the forums. Link goes to a nice looking UA solution.
     
    Last edited: Aug 24, 2014
  4. Beyerdynamic

    Beyerdynamic

    Joined:
    Dec 9, 2012
    Posts:
    27
    Worked for me, just edit the FB.cs script and look for #if Unity_4_5. Then change it to #if Unity_4_6. Simple. :)
     
    senseiGoodie, prg1 and SNSD like this.
  5. SiMKiNG

    SiMKiNG

    Joined:
    Dec 2, 2013
    Posts:
    14
    Thanks man it worked for me... Althoughhhhh it works on my comp now but once uploaded to my phone nothing happens when i click the FB button i don't get why it works on my comp but not on my android device!! Arrrr please help

    would it happen to have something with this notice...
    Game scripts or other custom code contains OnMouse_ event handlers. Presence of such handlers might impact performance on handheld devices.
    UnityEditor.BuildPlayerWindow:BuildPlayerAndRun()
     
  6. paskal007r

    paskal007r

    Joined:
    Sep 6, 2013
    Posts:
    68
    @BoredMormon
    Man, you are to a saved-the-christmas level right now <3
    Thank you SO MUCH!
     
    Abhijit-Mukherjee likes this.
  7. Abhijit-Mukherjee

    Abhijit-Mukherjee

    Joined:
    Jan 9, 2015
    Posts:
    193
  8. The_Devil

    The_Devil

    Joined:
    Jun 6, 2015
    Posts:
    36
    This happened to me while using FB SDK 6.2.2 and Unity 5.1.0f3. Had to change the file FB.cs from
    Code (CSharp):
    1. #if UNITY_4_5 || UNITY_4_6 || UNITY_5_0 ||
    to
    Code (CSharp):
    1. #if UNITY_4_5 || UNITY_4_6 || UNITY_5_0 || UNITY_5
    and then it worked.
     
    milox777, dregan and mrqasim like this.
  9. Kiwasi

    Kiwasi

    Joined:
    Dec 5, 2013
    Posts:
    16,860
    If you are not going to go back to older versions with the project its better to just remove the pre-processor code. Entirely delete the code for the older version, and remove the pre-processor directives around the new code. That way you don't need to keep making changes every time there is a point update.
     
  10. mrqasim

    mrqasim

    Joined:
    Jul 27, 2015
    Posts:
    1
    You Awsome :)
     
  11. faraz

    faraz

    Joined:
    Aug 4, 2014
    Posts:
    46
    Thanks man,
    I have unity 5.1 but it was not mention in FB.cs, so i added it in last like this

    Code (CSharp):
    1. #if !UNITY_WINRT
    2.             #if UNITY_4_5 || UNITY_4_6 || UNITY_5_0|| UNITY_5_0 || UNITY_5_1
    Thanks for the tip!