Search Unity

Resolved How to use Facebook SDK in unity for mobile devices (Android & iOS)?

Discussion in 'Scripting' started by pur3bl00d, Jul 5, 2022.

  1. pur3bl00d

    pur3bl00d

    Joined:
    Jan 21, 2019
    Posts:
    8
    It's been like 7 days, where I am trying to figure out using Facebook SDK in unity. I used Unity 2021.3.4f1 and current 2021.3.5f1 to test the SDK. I want to use Facebook SDK with Auth for my mobile game.

    • I used Facebook SDK 13, 12 but it crash both unity version (2021.3.4f1, 2021.3.5f1) and I have to open unity again.

    • Again I used Facebook SDK 9, 9.2, 11 it work in both editor but crash in android app while opening; it doesn't even open, it immediately crash.
    What do u do if u ask: I only Init the FB where i use this code in Start()

    Code (CSharp):
    1. FB.Init(this.initComplete, this.onHideUnity);
    I follow every tutorial, guides nothing is working, some time PlayerServiceResolver make weird error (Google.IOSResolver_v1.2.135.0.dll' will not be loaded due to errors:) because of that I remove the PlayServiceResolver (which comes with package) with ExternalDependencyManager.

    It's very annoying with this unity Facebook SDK, I saw their Github repo, many people are saying their project basically comes with full of bugs.

    So my question is how do u guys implement Facebook SDK in unity for Auth;
     
  2. pur3bl00d

    pur3bl00d

    Joined:
    Jan 21, 2019
    Posts:
    8
    After 8 hour of testing, I found out that Facebook SDK 12, 13 does not work in new unity editor (2021.3.4f1, 2021.3.5f1) even in Play Mode. So what work for me is Facebook SDK 11, I posted some images step by step how to use it.
    Note* I only tested on my system.

    Steps
    1. Download and install OpenSSL (basically used for keystore thing for android)
      1. It will automatically added to environmental path if not manually add it to path.
      2. and restart the computer.
    2. Switch platform in unity to android.
    3. Go to Facebook SDK download site and download SDK 11
    4. Import Facebook SDK 11 in unity.
      1. Asset > Import Package > Custom Package...
      2. Import only what's needed (see image for reference) do not import PlayServicesResolver and examples it will mess things up.
      3. After importing there will some issue with precompiled assemblies (i.e. .dll files) just update them.
      4. There will be issue with Google.VersionHandler so we need to import External dependencies manager.
      5. Import external dependencies manager in unity. (note it will take some time to compile the script be patient)
      6. There will be dialog Enable Android auto resolution just Enable it.
      7. After enabling there will be some resolving by External dependencies manager it will take time but after finishing it there will be multiple jar, aar files in Plugins > Android directory.
    5. Now for Important part; Facebook Developer dashboard.
      1. Login into Facebook developer dashboard and create app (Watch this tutorial if you don't know how to)
      2. Watch this tutorial to config the sdk in unity. (this tutorial use sdk 9.0 basically it doesnot work properly in new unity editor) but the steps are same in sdk 11.
    If some error comes about android Failed to Update Android SDK Package List watch this tutorial.
    P.S: I also attach simple Test.cs file.
     

    Attached Files:

  3. Julian-Unity3D

    Julian-Unity3D

    Unity Technologies

    Joined:
    Apr 28, 2022
    Posts:
    192
    Apologies for the late response,
    I'm glad to see you got it working
     
    boulakhoury likes this.
  4. usefulgames1

    usefulgames1

    Joined:
    Mar 17, 2022
    Posts:
    1
    Thank you so much buddy! You have no idea how much you helped me!
     
  5. softitygokay

    softitygokay

    Joined:
    Sep 23, 2022
    Posts:
    1
  6. boulakhoury

    boulakhoury

    Joined:
    Sep 30, 2018
    Posts:
    2
    Thank you a lot for that great solution !
    I have been like more then 5 days struggling with that issue.

    Again awesome solution and Thank you !
     
  7. Playloom

    Playloom

    Joined:
    Jan 20, 2020
    Posts:
    2
    Thanks so much for your solution... I'm using unity 2019.4(LTS)... I hope it works too
    :):):)