java.lang.ClassNotFoundException: com.facebook.unity.FB whenever I test my build
Asked Answered
W

2

5

I'm trying to incorporate the official Android SDK for Unity to my project. After I set everything on the facebook options inside Unity and make my build, everytime FB.Init() is called I get this:

AndroidJavaException: java.lang.ClassNotFoundException: com.facebook.unity.FB
  at UnityEngine.AndroidJNISafe.CheckException () [0x00000] in <filename unknown>:0
  at UnityEngine.AndroidJNISafe.CallStaticObjectMethod (IntPtr clazz, IntPtr methodID, UnityEngine.jvalue[] args) [0x00000] in <filename unknown>:0
  at UnityEngine.AndroidJavaObject._CallStatic[AndroidJavaObject] (System.String methodName, System.Object[] args) [0x00000] in <filename unknown>:0
  at UnityEngine.AndroidJavaObject.CallStatic[AndroidJavaObject] (System.String methodName, System.Object[] args) [0x00000] in <filename unknown>:0
  at UnityEngine.AndroidJavaObject.FindClass (System.String name) [0x00000] in <filename unknown>:0
  at UnityEngine.AndroidJavaClass._AndroidJavaClass (System.String className) [0x00000] in <filename unknown>:0
  at UnityEngine.AndroidJavaClass..ctor (System.String className) [0x00000] in <filename unknown>:0
  at Facebook.AndroidFacebook.get_FB () [0x0000b] in C:\Users\motionart\Documents\Unity Projects\

I even have 'Development Build' and 'Script Debugging' enabled but everything happens on <filename unknown> so I don't really know how to proceed.

Any idea what could be happening?

Wealth answered 19/12, 2013 at 21:37 Comment(2)
Did you add the sdk to your project?Guyenne
did you integrate any other sdk along with facebook sdk in your project?Sheffy
O
6

I had this error, too. Not only with Facebook, but with other plugins (google, etc), as well.

enter image description here

Update your proguard-user.txt to inlude the Facebook classes -keep class com.facebook.** { *; }

  1. Go to Player Settings
  2. Check Custom Proguard File
  3. Open /Plugins/Android/proguard-user.txt
  4. Add -keep class com.facebook.** { *; }

This will not remove Facebook classes when you make a new build.

Ofelia answered 13/9, 2020 at 10:47 Comment(0)
W
4

The SDK was in my project and it was the only one. After struggling with this for a few hours, the only thing that fixed the problem was to delete all traces of the sdk from my project and import it again.

Then it worked.

Wealth answered 20/12, 2013 at 14:30 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.