使用适用于 Android 的 Facebook Unity SDK 登录 facebook 时应用程序强制关闭
Posted
技术标签:
【中文标题】使用适用于 Android 的 Facebook Unity SDK 登录 facebook 时应用程序强制关闭【英文标题】:Application force closes when logging in to facebook with Facebook Unity SDK for Android 【发布时间】:2014-03-25 17:48:48 【问题描述】:我创建了一个简单的按钮,用于在我的游戏中使用 Facebook Unity SDK 测试 Facebook 登录。登录在 Unity 编辑器中完美运行,但在我的 HTC 资源管理器上进行测试时应用程序强制关闭。还在 BlueStacks 上测试了游戏,在尝试登录时它也崩溃了。
统一构建游戏时,最后出现以下错误:
您的 android 设置不正确。请参阅 Facebook 菜单中的设置。
UnityEditor.HostView:OnGUI()
我正在使用 Facebook Unity SDK 5.0.3 和 Unity 4.3.0
我也尝试按照here的建议更改 android 清单
我还使用 openssl 创建了 keyhash 并将其粘贴在 Facebook 应用程序设置页面上,因为 unity 不会在检查器的“Android Build Facebook Settings”中显示密钥哈希值。
我是 Unity 的新手,并且已经坚持了很长时间。请有人帮忙。
下面是logcat:
03-25 22:03:09.726: D/dalvikvm(7014): GC_CONCURRENT freed 1809K, 32% free 8385K/12295K, external 0K/0K, paused 54ms+111ms
03-25 22:03:09.766: D/FBUnitySDK(7077): KeyHash: TC01uDQHTkrLbLaTLSfdTA/bEuI=
03-25 22:03:09.766: D/AndroidRuntime(7077): Shutting down VM
03-25 22:03:09.766: W/dalvikvm(7077): threadid=1: thread exiting with uncaught exception (group=0x4020b5a0)
03-25 22:03:09.776: E/AndroidRuntime(7077): FATAL EXCEPTION: main
03-25 22:03:09.776: E/AndroidRuntime(7077): java.lang.Error: FATAL EXCEPTION [main]
03-25 22:03:09.776: E/AndroidRuntime(7077): Unity version : 4.3.0f4
03-25 22:03:09.776: E/AndroidRuntime(7077): Device model : HTC HTC Explorer A310e
03-25 22:03:09.776: E/AndroidRuntime(7077): Device fingerprint: htc_asia_india/htc_pico/pico:2.3.5/GRJ90/214721.3:user/release-keys
03-25 22:03:09.776: E/AndroidRuntime(7077): Caused by: java.lang.NoClassDefFoundError: android.support.v4.content.LocalBroadcastManager
03-25 22:03:09.776: E/AndroidRuntime(7077): at com.facebook.Session.postActiveSessionAction(Session.java:1328)
03-25 22:03:09.776: E/AndroidRuntime(7077): at com.facebook.Session.setActiveSession(Session.java:790)
03-25 22:03:09.776: E/AndroidRuntime(7077): at com.facebook.unity.FB.initAndLogin(FB.java:86)
03-25 22:03:09.776: E/AndroidRuntime(7077): at com.facebook.unity.FB.LoginUsingActivity(FB.java:249)
03-25 22:03:09.776: E/AndroidRuntime(7077): at com.facebook.unity.FBUnityLoginActivity.onCreate(FBUnityLoginActivity.java:13)
03-25 22:03:09.776: E/AndroidRuntime(7077): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1072)
03-25 22:03:09.776: E/AndroidRuntime(7077): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1836)
03-25 22:03:09.776: E/AndroidRuntime(7077): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1893)
03-25 22:03:09.776: E/AndroidRuntime(7077): at android.app.ActivityThread.access$1500(ActivityThread.java:135)
03-25 22:03:09.776: E/AndroidRuntime(7077): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1054)
03-25 22:03:09.776: E/AndroidRuntime(7077): at android.os.Handler.dispatchMessage(Handler.java:99)
03-25 22:03:09.776: E/AndroidRuntime(7077): at android.os.Looper.loop(Looper.java:150)
03-25 22:03:09.776: E/AndroidRuntime(7077): at android.app.ActivityThread.main(ActivityThread.java:4389)
03-25 22:03:09.776: E/AndroidRuntime(7077): at java.lang.reflect.Method.invokeNative(Native Method)
03-25 22:03:09.776: E/AndroidRuntime(7077): at java.lang.reflect.Method.invoke(Method.java:507)
03-25 22:03:09.776: E/AndroidRuntime(7077): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:849)
03-25 22:03:09.776: E/AndroidRuntime(7077): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:607)
03-25 22:03:09.776: E/AndroidRuntime(7077): at dalvik.system.NativeStart.main(Native Method)
03-25 22:03:09.776: E/EmbeddedLogger(176): App crashed! Process: com.jalanubha.Progamer
03-25 22:03:09.786: E/EmbeddedLogger(176): App crashed! Package: com.jalanubha.Progamer v1 (1.0)
03-25 22:03:09.786: E/EmbeddedLogger(176): Error getting package label: com.jalanubha.Progamer
03-25 22:03:09.786: E/EmbeddedLogger(176): java.lang.NullPointerException
03-25 22:03:09.786: E/EmbeddedLogger(176): at com.htc.server.embedded.EmbeddedLogger.onHandleApplicationCrash(EmbeddedLogger.java:59)
03-25 22:03:09.786: E/EmbeddedLogger(176): at com.android.server.am.ActivityManagerService.handleApplicationCrash(ActivityManagerService.java:7739)
03-25 22:03:09.786: E/EmbeddedLogger(176): at android.app.ActivityManagerNative.onTransact(ActivityManagerNative.java:1033)
03-25 22:03:09.786: E/EmbeddedLogger(176): at com.android.server.am.ActivityManagerService.onTransact(ActivityManagerService.java:1657)
03-25 22:03:09.786: E/EmbeddedLogger(176): at android.os.Binder.execTransact(Binder.java:320)
03-25 22:03:09.786: E/EmbeddedLogger(176): at com.android.server.SystemServer.init1(Native Method)
03-25 22:03:09.786: E/EmbeddedLogger(176): at com.android.server.SystemServer.main(SystemServer.java:1083)
03-25 22:03:09.786: E/EmbeddedLogger(176): at java.lang.reflect.Method.invokeNative(Native Method)
03-25 22:03:09.786: E/EmbeddedLogger(176): at java.lang.reflect.Method.invoke(Method.java:507)
03-25 22:03:09.786: E/EmbeddedLogger(176): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:849)
03-25 22:03:09.786: E/EmbeddedLogger(176): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:607)
03-25 22:03:09.786: E/EmbeddedLogger(176): at dalvik.system.NativeStart.main(Native Method)
03-25 22:03:09.786: E/EmbeddedLogger(176): Application Label: <ERROR>
03-25 22:03:09.786: W/ActivityManager(176): Force finishing activity com.jalanubha.Progamer/com.facebook.unity.FBUnityLoginActivity
03-25 22:03:09.786: W/ActivityManager(176): Force finishing activity com.jalanubha.Progamer/com.unity3d.player.UnityPlayerNativeActivity
03-25 22:03:09.846: D/WindowManagerImpl(176): addView, new view, mViews[1]: com.android.internal.policy.impl.PhoneWindow$DecorView@40c36d00
03-25 22:03:10.147: W/fb4a(:<default>):BlueServiceQueue(7014): Exception during service
03-25 22:03:10.147: W/fb4a(:<default>):BlueServiceQueue(7014): java.net.UnknownHostException: graph.facebook.com
03-25 22:03:10.147: W/fb4a(:<default>):BlueServiceQueue(7014): at java.net.InetAddress.lookupHostByName(InetAddress.java:512)
03-25 22:03:10.147: W/fb4a(:<default>):BlueServiceQueue(7014): at java.net.InetAddress.getAllByNameImpl(InetAddress.java:300)
03-25 22:03:10.147: W/fb4a(:<default>):BlueServiceQueue(7014): at java.net.InetAddress.getAllByName(InetAddress.java:259)
03-25 22:03:10.147: W/fb4a(:<default>):BlueServiceQueue(7014): at com.facebook.http.common.executorimpl.apache.FbHttpClientConnectionOperator.openConnection(FbHttpClientConnectionOperator.java:133)
03-25 22:03:10.147: W/fb4a(:<default>):BlueServiceQueue(7014): at org.apache.http.impl.conn.AbstractPoolEntry.open(AbstractPoolEntry.java:164)
03-25 22:03:10.147: W/fb4a(:<default>):BlueServiceQueue(7014): at org.apache.http.impl.conn.AbstractPooledConnAdapter.open(AbstractPooledConnAdapter.java:119)
03-25 22:03:10.147: W/fb4a(:<default>):BlueServiceQueue(7014): at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:359)
03-25 22:03:10.147: W/fb4a(:<default>):BlueServiceQueue(7014): at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:555)
03-25 22:03:10.147: W/fb4a(:<default>):BlueServiceQueue(7014): at com.facebook.http.common.executorimpl.apache.FbHttpClientImpl.execute(FbHttpClientImpl.java:160)
03-25 22:03:10.147: W/fb4a(:<default>):BlueServiceQueue(7014): at com.facebook.http.common.executorimpl.apache.FbHttpClientImpl.execute(FbHttpClientImpl.java:148)
03-25 22:03:10.147: W/fb4a(:<default>):BlueServiceQueue(7014): at com.facebook.http.common.executorimpl.apache.FbHttpClientRequestExecutor.a(FbHttpClientRequestExecutor.java:60)
03-25 22:03:10.147: W/fb4a(:<default>):BlueServiceQueue(7014): at com.facebook.http.executors.qebased.QeHttpRequestExecutor.a(QeHttpRequestExecutor.java:61)
03-25 22:03:10.147: W/fb4a(:<default>):BlueServiceQueue(7014): at com.facebook.http.common.RequestFlowStateController.a(RequestFlowStateController.java:89)
03-25 22:03:10.147: W/fb4a(:<default>):BlueServiceQueue(7014): at com.facebook.http.common.FbRedirectController.a(FbRedirectController.java:93)
03-25 22:03:10.147: W/fb4a(:<default>):BlueServiceQueue(7014): at com.facebook.http.common.FbHttpRequestProcessor.b(FbHttpRequestProcessor.java:173)
03-25 22:03:10.147: W/fb4a(:<default>):BlueServiceQueue(7014): at com.facebook.http.common.FbHttpRequestProcessor.a(FbHttpRequestProcessor.java:148)
03-25 22:03:10.147: W/fb4a(:<default>):BlueServiceQueue(7014): at com.facebook.http.common.FbHttpRequestProcessor.b(FbHttpRequestProcessor.java:103)
03-25 22:03:10.147: W/fb4a(:<default>):BlueServiceQueue(7014): at com.facebook.http.common.FbHttpRequestProcessor.a(FbHttpRequestProcessor.java:241)
03-25 22:03:10.147: W/fb4a(:<default>):BlueServiceQueue(7014): at com.facebook.http.protocol.SingleMethodRunnerImpl.a(SingleMethodRunnerImpl.java:402)
03-25 22:03:10.147: W/fb4a(:<default>):BlueServiceQueue(7014): at com.facebook.http.protocol.SingleMethodRunnerImpl.a(SingleMethodRunnerImpl.java:164)
03-25 22:03:10.147: W/fb4a(:<default>):BlueServiceQueue(7014): at com.facebook.http.protocol.AbstractSingleMethodRunner.a(AbstractSingleMethodRunner.java:26)
03-25 22:03:10.147: W/fb4a(:<default>):BlueServiceQueue(7014): at com.facebook.http.protocol.ApiMethodRunnerImpl.a(ApiMethodRunnerImpl.java:43)
03-25 22:03:10.147: W/fb4a(:<default>):BlueServiceQueue(7014): at com.facebook.http.protocol.ApiMethodRunnerImpl.a(ApiMethodRunnerImpl.java:35)
03-25 22:03:10.147: W/fb4a(:<default>):BlueServiceQueue(7014): at com.facebook.orca.protocol.WebServiceHandler.b(WebServiceHandler.java:174)
03-25 22:03:10.147: W/fb4a(:<default>):BlueServiceQueue(7014): at com.facebook.orca.server.AbstractBlueServiceHandlerFilter.a(AbstractBlueServiceHandlerFilter.java:31)
03-25 22:03:10.147: W/fb4a(:<default>):BlueServiceQueue(7014): at com.facebook.fbservice.service.FilterChainLink.a(FilterChainLink.java:20)
03-25 22:03:10.147: W/fb4a(:<default>):BlueServiceQueue(7014): at com.facebook.orca.database.DbServiceHandler.b(DbServiceHandler.java:259)
03-25 22:03:10.147: W/fb4a(:<default>):BlueServiceQueue(7014): at com.facebook.orca.server.AbstractBlueServiceHandlerFilter.a(AbstractBlueServiceHandlerFilter.java:31)
03-25 22:03:10.147: W/fb4a(:<default>):BlueServiceQueue(7014): at com.facebook.fbservice.service.FilterChainLink.a(FilterChainLink.java:20)
03-25 22:03:10.147: W/fb4a(:<default>):BlueServiceQueue(7014): at com.facebook.orca.cache.CacheServiceHandler.b(CacheServiceHandler.java:138)
03-25 22:03:10.147: W/fb4a(:<default>):BlueServiceQueue(7014): at com.facebook.orca.server.AbstractBlueServiceHandlerFilter.a(AbstractBlueServiceHandlerFilter.java:31)
03-25 22:03:10.147: W/fb4a(:<default>):BlueServiceQueue(7014): at com.facebook.fbservice.service.FilterChainLink.a(FilterChainLink.java:20)
03-25 22:03:10.147: W/fb4a(:<default>):BlueServiceQueue(7014): at com.facebook.fbservice.service.BlueServiceQueue.e(BlueServiceQueue.java:302)
03-25 22:03:10.147: W/fb4a(:<default>):BlueServiceQueue(7014): at com.facebook.fbservice.service.BlueServiceQueue.d(BlueServiceQueue.java:54)
03-25 22:03:10.147: W/fb4a(:<default>):BlueServiceQueue(7014): at com.facebook.fbservice.service.BlueServiceQueue$3.run(BlueServiceQueue.java:232)
03-25 22:03:10.147: W/fb4a(:<default>):BlueServiceQueue(7014): at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:444)
03-25 22:03:10.147: W/fb4a(:<default>):BlueServiceQueue(7014): at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:306)
03-25 22:03:10.147: W/fb4a(:<default>):BlueServiceQueue(7014): at java.util.concurrent.FutureTask.run(FutureTask.java:138)
03-25 22:03:10.147: W/fb4a(:<default>):BlueServiceQueue(7014): at com.facebook.common.executors.ListenableScheduledFutureImpl.run(ListenableScheduledFutureImpl.java:59)
03-25 22:03:10.147: W/fb4a(:<default>):BlueServiceQueue(7014): at android.os.Handler.handleCallback(Handler.java:587)
03-25 22:03:10.147: W/fb4a(:<default>):BlueServiceQueue(7014): at android.os.Handler.dispatchMessage(Handler.java:92)
03-25 22:03:10.147: W/fb4a(:<default>):BlueServiceQueue(7014): at android.os.Looper.loop(Looper.java:150)
03-25 22:03:10.147: W/fb4a(:<default>):BlueServiceQueue(7014): at android.os.HandlerThread.run(HandlerThread.java:60)
03-25 22:03:10.287: W/ActivityManager(176): Activity pause timeout for HistoryRecord40b04798 com.jalanubha.Progamer/com.facebook.unity.FBUnityLoginActivity
【问题讨论】:
【参考方案1】:在项目属性中的 Order 和 Export 下,确保您已选中 Android Private Libraries 复选框
【讨论】:
以上是关于使用适用于 Android 的 Facebook Unity SDK 登录 facebook 时应用程序强制关闭的主要内容,如果未能解决你的问题,请参考以下文章
Android Asmack xmpp 登录仅适用于我自己的 Facebook 帐户
适用于 Android 的 iOS Facebook 幻灯片菜单 [关闭]
适用于 Android 的 XMPP/facebook 聊天连接
测试适用于 Android 的 Facebook 应用广告 SDK