Search code examples
androidunity-game-enginefacebook-unity-sdk

Unity 2017 Facebook Init error AndroidJavaException: java.lang.ClassNotFoundException: com.facebook.unity.FB


Getting this error when calling FB.Init in the Facebook-provided example scenes:

AndroidJavaException: java.lang.ClassNotFoundException: com.facebook.unity.FB
java.lang.ClassNotFoundException: com.facebook.unity.FB
    at java.lang.Class.classForName(Native Method)
    at java.lang.Class.forName(Class.java:324)
    at java.lang.Class.forName(Class.java:285)
    at com.unity3d.player.UnityPlayer.nativeRender(Native Method)
    at com.unity3d.player.UnityPlayer.c(Unknown Source)
    at com.unity3d.player.UnityPlayer$c$1.handleMessage(Unknown Source)
    at android.os.Handler.dispatchMessage(Handler.java:98)
    at android.os.Looper.loop(Looper.java:148)
    at com.unity3d.player.UnityPlayer$c.run(Unknown Source)
Caused by: java.lang.ClassNotFoundException: Didn't find class "com.facebook.unity.FB" on path: DexPathList[[zip file "/data/app/com.redacted.redacted-1/base.apk"],nativeLibraryDirectories=[/data/app/com.redacted.redacted-1/lib/arm, /data/app/com.redacted.redacted-1/base.apk!/lib/armeabi-v7a, /vendor/lib, /system/lib]]

Using Facebook Unity SDK 7.10.0 and Unity 2017.1.0f3, building using Gradle. I've tried deleting and re-adding the SDK like another similar post said worked for them but I'm still getting the issue. All Facebook settings should be correct because it works great on iOS.

Facebook SDK and Firebase Authentication SDK are the only things in the project.

Any help is appreciated!

EDIT - It appears to be a compatability issue with Unity 2017.1.0f3. I've rolled back to Unity 5.6.2f1 and it functions perfectly.


Solution

  • Got it working in Unity 2017 by double checking all my settings and switching from Gradle back to internal build.