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?
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.
I had this error, too. Not only with Facebook, but with other plugins (google, etc), as well.
Update your proguard-user.txt
to inlude the Facebook classes -keep class com.facebook.** { *; }
-keep class com.facebook.** { *; }
Player Settings
Custom Proguard File
/Plugins/Android/proguard-user.txt
-keep class com.facebook.** { *; }
-keep class com.facebook.** { *; }
This will not remove Facebook classes when you make a new build.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.