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

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()

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;

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

  • Download and install OpenSSL (basically used for keystore thing for android)

  • It will automatically added to environmental path if not manually add it to path.

  • and restart the computer.

  • Switch platform in unity to android.

  • Go to Facebook SDK download site and download SDK 11

  • Import Facebook SDK 11 in unity.

  • Asset > Import Package > Custom Package…

  • Import only what’s needed (see image for reference) do not import PlayServicesResolver and examples it will mess things up.

  • After importing there will some issue with precompiled assemblies (i.e. .dll files) just update them.

  • There will be issue with Google.VersionHandler so we need to import External dependencies manager.

  • Import external dependencies manager in unity. (note it will take some time to compile the script be patient)

  • There will be dialog Enable Android auto resolution just Enable it.

  • 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.

  • Now for Important part; Facebook Developer dashboard.

  • Login into Facebook developer dashboard and create app (Watch this tutorial if you don’t know how to)

  • 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.


8256921–1080810–Test.cs (1.16 KB)

4 Likes

Apologies for the late response,
I’m glad to see you got it working

1 Like

Thank you so much buddy! You have no idea how much you helped me!

thx

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 !

Thanks so much for your solution… I’m using unity 2019.4(LTS)… I hope it works too
:):):slight_smile: