这是我第一个使用https://developers.facebook.com/docs/android/getting-started/facebook-sdk-for-android/和https://developers.facebook.com/docs/android/getting-started/facebook-sdk-for-android/的官方教程学习的Android应用程序 {{3}} 我按照app_id,Hash键,refrenced库包含的教程一步一步地进行了操作,但是一旦在模拟器上启动应用程序,就会出现强制关闭应用程序错误。 我的logcat如下
10-16 20:48:13.169: D/AndroidRuntime(639): Shutting down VM
10-16 20:48:13.169: W/dalvikvm(639): threadid=1: thread exiting with uncaught exception (group=0x4001d800)
10-16 20:48:13.229: E/AndroidRuntime(639): FATAL EXCEPTION: main
10-16 20:48:13.229: E/AndroidRuntime(639): java.lang.RuntimeException: Unable to instantiate application com.facebook.myagent.MyAgent: java.lang.ClassNotFoundException: com.facebook.myagent.MyAgent in loader dalvik.system.PathClassLoader[/data/app/com.facebook.myagent-2.apk]
10-16 20:48:13.229: E/AndroidRuntime(639): at android.app.ActivityThread$PackageInfo.makeApplication(ActivityThread.java:649)
10-16 20:48:13.229: E/AndroidRuntime(639): at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4232)
10-16 20:48:13.229: E/AndroidRuntime(639): at android.app.ActivityThread.access$3000(ActivityThread.java:125)
10-16 20:48:13.229: E/AndroidRuntime(639): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2071)
10-16 20:48:13.229: E/AndroidRuntime(639): at android.os.Handler.dispatchMessage(Handler.java:99)
10-16 20:48:13.229: E/AndroidRuntime(639): at android.os.Looper.loop(Looper.java:123)
10-16 20:48:13.229: E/AndroidRuntime(639): at android.app.ActivityThread.main(ActivityThread.java:4627)
10-16 20:48:13.229: E/AndroidRuntime(639): at java.lang.reflect.Method.invokeNative(Native Method)
10-16 20:48:13.229: E/AndroidRuntime(639): at java.lang.reflect.Method.invoke(Method.java:521)
10-16 20:48:13.229: E/AndroidRuntime(639): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
10-16 20:48:13.229: E/AndroidRuntime(639): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
10-16 20:48:13.229: E/AndroidRuntime(639): at dalvik.system.NativeStart.main(Native Method)
10-16 20:48:13.229: E/AndroidRuntime(639): Caused by: java.lang.ClassNotFoundException: com.facebook.myagent.MyAgent in loader dalvik.system.PathClassLoader[/data/app/com.facebook.myagent-2.apk]
10-16 20:48:13.229: E/AndroidRuntime(639): at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:243)
10-16 20:48:13.229: E/AndroidRuntime(639): at java.lang.ClassLoader.loadClass(ClassLoader.java:573)
10-16 20:48:13.229: E/AndroidRuntime(639): at java.lang.ClassLoader.loadClass(ClassLoader.java:532)
10-16 20:48:13.229: E/AndroidRuntime(639): at android.app.Instrumentation.newApplication(Instrumentation.java:942)
10-16 20:48:13.229: E/AndroidRuntime(639): at android.app.ActivityThread$PackageInfo.makeApplication(ActivityThread.java:644)
10-16 20:48:13.229: E/AndroidRuntime(639): ... 11 more
10-16 20:48:15.449: I/Process(639): Sending signal. PID: 639 SIG: 9
答案 0 :(得分:0)
你有一个粗俗的例外。 问题是一个线程无法处理来自Facebook的UI和后台操作。 要么添加另一个只执行web / Facebook内容的Thread。 或者使用AsyncTask,这是这种情况下的最佳实践。 检查这个教程:http://www.youtube.com/watch?v=JVaGZwuYmck