Search Unity

Problem with latest Facebook SDK on Canvas

Discussion in 'Web' started by rankornfeld, Mar 21, 2018.

  1. rankornfeld

    rankornfeld

    Joined:
    Sep 29, 2016
    Posts:
    57
    I have updated my game to the latest facebook SDK 7.11.1

    When trying to run my game on Facebook using WebGL, I get the following error:
    FileNotFoundException: Could not load file or assembly 'Facebook.Unity.Canvas' or one of its dependencies. The system cannot find the file specified.

    This happen when I try to call FB.Init()

    On the previous version it used to work, and I have imported the entire SDK without changing anything.

    Anyone seen this problem or have any idea what to check?
     
  2. rankornfeld

    rankornfeld

    Joined:
    Sep 29, 2016
    Posts:
    57
    So I think I tracked the problem to the following line in the Facebook SDK (CanvasFacebook.cs:57):

    Assembly assembly = Assembly.Load("Facebook.Unity.Canvas");

    I think it's related to code striping, as Unity does not think the assembly is needed.
    I have tried to update link.xml to preserve this assembly but without success.

    For now I am moving back to Facebook SDK 7.10, until this is resolved.
     
    olegzheleztsov likes this.
  3. MoinTom

    MoinTom

    Joined:
    May 8, 2015
    Posts:
    15
  4. lwx5924

    lwx5924

    Joined:
    May 9, 2017
    Posts:
    3
    Did you find any solution?
     
  5. kwikdev

    kwikdev

    Joined:
    Jun 13, 2013
    Posts:
    31
    I see the same thing in 2017.4.1f1. Is it possible that Facebook did not test their code in a WebGL build? FB.Init() seems like the first step of every test case.
     
  6. Deathwing

    Deathwing

    Joined:
    May 8, 2013
    Posts:
    25
    Hey guys,

    I will just post my answer which I just gave at the github issue #147 here:

    I created a pull request #160 , which should fix that issue for you (I had the same issue, but now everything is working again with FB SDK 7.10+).

    The only thing I haven't tested is the ability to log out and in again in the Facebook WebGL game (because in our game you can't log out in a facebook WebGL game, and Facebook is automatically signing you in with the init call.

    If you don't want to wait until Facebook has merged it or fixed it on their own, here are the steps to fix the broken WebGL build:

    1. Replace the CanvasJSSDKBindings.jslib with the one of my pull request link
      (if your project is missing the file, Copy mine into [ProjectRoot]/Assets/FacebookSDK/Plugins/Canvas/Plugins/)
    2. If you use code stripping, at the following line to your link.xml (or the Facebook link.xml):
      Code (CSharp):
      1. <assembly fullname="Facebook.Unity.Canvas" ignoreIfMissing="1">
      2. <type fullname="Facebook.Unity.Canvas.*" preserve="all"/>
      3. </assembly>
    3. If you are missing the Facebook.Unity.Canvas.dll (because it is not in the UnityPackage of the FB Unity SDK):
      Download the FB Unity SDK repo and build the [repo]/Facebook.Unity.Canvas/Facebook.Unity.Canvas.sln, after that copy the [repo]/Facebook.Unity.Canvas/bin/release/Facebook.Unity.Canvas.dll to your [ProjectRoot]/Assets/FacebookSDK/Plugins/Canvas/ folder
     
  7. Deathwing

    Deathwing

    Joined:
    May 8, 2013
    Posts:
    25
    I pushed fixes for Login and LogAppEvent, can be found on the Pull Request and also on my Repo.
     
  8. rankornfeld

    rankornfeld

    Joined:
    Sep 29, 2016
    Posts:
    57
    Hi Deathwing

    Been trying to build the SDK from your repository, but the setup.sh scripts fails every time.

    The problem seems to be that tar cannot decompress the play-services-resolver_v1.2.62.0 unitypackage file.

    I have Unity 2017.4 but have also tried with 2017.1

    Any idea what might be wrong?

    Thanks
     
  9. rankornfeld

    rankornfeld

    Joined:
    Sep 29, 2016
    Posts:
    57
  10. SamuelGoldenbaum

    SamuelGoldenbaum

    Joined:
    May 21, 2017
    Posts:
    47
  11. Pincape

    Pincape

    Joined:
    Dec 4, 2018
    Posts:
    5
    Had this problem but was able to solve by choosing WebGL as target platform in Build Settings instead of Facebook.