[英]java.lang.ClassNotFoundException: com.facebook.unity.FB whenever I test my build
I'm trying to incorporate the official Android SDK for Unity to my project.我正在尝试将用于 Unity 的官方 Android SDK 合并到我的项目中。 After I set everything on the facebook options inside Unity and make my build, everytime FB.Init() is called I get this:
在我在 Unity 中的 facebook 选项上设置所有内容并进行构建后,每次调用 FB.Init() 时,我都会得到以下信息:
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.我什至启用了“开发构建”和“脚本调试”,但一切都发生在
<filename unknown>
所以我真的不知道如何继续。
Any idea what could be happening?知道会发生什么吗?
The SDK was in my project and it was the only one. SDK 在我的项目中,它是唯一的一个。 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.
在为此苦苦挣扎了几个小时后,解决问题的唯一方法是从我的项目中删除 sdk 的所有痕迹并再次导入。
Then it worked.然后它起作用了。
I had this error, too.我也有这个错误。 Not only with Facebook, but with other plugins (google, etc), as well.
不仅是 Facebook,还有其他插件(谷歌等)。
Update your proguard-user.txt
to inlude the Facebook classes -keep class com.facebook.** { *; }
更新您的
proguard-user.txt
以包含 Facebook 类-keep class com.facebook.** { *; }
-keep class com.facebook.** { *; }
Player Settings
Player Settings
Custom Proguard File
Custom Proguard File
/Plugins/Android/proguard-user.txt
/Plugins/Android/proguard-user.txt
-keep class com.facebook.** { *; }
-keep class com.facebook.** { *; }
-keep class com.facebook.** { *; }
This will not remove Facebook classes when you make a new build.当您进行新构建时,这不会删除 Facebook 类。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.