Android App在旋转时不断崩溃

时间:2013-08-27 16:28:36

标签: facebook facebook-graph-api android

我现在注意到,当我旋转手机时,我的应用程序崩溃了

我添加了以下堆栈跟踪

该应用程序基于Facebook Friend Smasher

08-27 19:18:57.616: D/AndroidRuntime(19379): Shutting down VM
08-27 19:18:57.616: W/dalvikvm(19379): threadid=1: thread exiting with uncaught exception (group=0x41a852a0)
08-27 19:18:57.636: E/AndroidRuntime(19379): FATAL EXCEPTION: main
08-27 19:18:57.636: E/AndroidRuntime(19379): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.facebook.android.tomatosmasher/com.facebook.android.friendsmash.HomeActivity}: android.view.InflateException: Binary XML file line #24: Error inflating class fragment
08-27 19:18:57.636: E/AndroidRuntime(19379):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2100)
08-27 19:18:57.636: E/AndroidRuntime(19379):    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2125)
08-27 19:18:57.636: E/AndroidRuntime(19379):    at android.app.ActivityThread.handleRelaunchActivity(ActivityThread.java:3553)
08-27 19:18:57.636: E/AndroidRuntime(19379):    at android.app.ActivityThread.access$700(ActivityThread.java:140)
08-27 19:18:57.636: E/AndroidRuntime(19379):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1233)
08-27 19:18:57.636: E/AndroidRuntime(19379):    at android.os.Handler.dispatchMessage(Handler.java:99)
08-27 19:18:57.636: E/AndroidRuntime(19379):    at android.os.Looper.loop(Looper.java:137)
08-27 19:18:57.636: E/AndroidRuntime(19379):    at android.app.ActivityThread.main(ActivityThread.java:4898)
08-27 19:18:57.636: E/AndroidRuntime(19379):    at java.lang.reflect.Method.invokeNative(Native Method)
08-27 19:18:57.636: E/AndroidRuntime(19379):    at java.lang.reflect.Method.invoke(Method.java:511)
08-27 19:18:57.636: E/AndroidRuntime(19379):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1006)
08-27 19:18:57.636: E/AndroidRuntime(19379):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:773)
08-27 19:18:57.636: E/AndroidRuntime(19379):    at dalvik.system.NativeStart.main(Native Method)
08-27 19:18:57.636: E/AndroidRuntime(19379): Caused by: android.view.InflateException: Binary XML file line #24: Error inflating class fragment
08-27 19:18:57.636: E/AndroidRuntime(19379):    at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:704)
08-27 19:18:57.636: E/AndroidRuntime(19379):    at android.view.LayoutInflater.rInflate(LayoutInflater.java:746)
08-27 19:18:57.636: E/AndroidRuntime(19379):    at android.view.LayoutInflater.inflate(LayoutInflater.java:489)
08-27 19:18:57.636: E/AndroidRuntime(19379):    at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
08-27 19:18:57.636: E/AndroidRuntime(19379):    at android.view.LayoutInflater.inflate(LayoutInflater.java:352)
08-27 19:18:57.636: E/AndroidRuntime(19379):    at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:308)
08-27 19:18:57.636: E/AndroidRuntime(19379):    at android.app.Activity.setContentView(Activity.java:1924)
08-27 19:18:57.636: E/AndroidRuntime(19379):    at com.facebook.android.friendsmash.HomeActivity.onCreate(HomeActivity.java:109)
08-27 19:18:57.636: E/AndroidRuntime(19379):    at android.app.Activity.performCreate(Activity.java:5206)
08-27 19:18:57.636: E/AndroidRuntime(19379):    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1083)
08-27 19:18:57.636: E/AndroidRuntime(19379):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2064)
08-27 19:18:57.636: E/AndroidRuntime(19379):    ... 12 more
08-27 19:18:57.636: E/AndroidRuntime(19379): Caused by: java.lang.NullPointerException
08-27 19:18:57.636: E/AndroidRuntime(19379):    at com.facebook.android.friendsmash.FBLoggedOutHomeFragment.onCreateView(FBLoggedOutHomeFragment.java:63)
08-27 19:18:57.636: E/AndroidRuntime(19379):    at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:846)
08-27 19:18:57.636: E/AndroidRuntime(19379):    at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1061)
08-27 19:18:57.636: E/AndroidRuntime(19379):    at android.support.v4.app.FragmentActivity.onCreateView(FragmentActivity.java:291)
08-27 19:18:57.636: E/AndroidRuntime(19379):    at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:676)
08-27 19:18:57.636: E/AndroidRuntime(19379):    ... 22 more

从hor转到ver

时保持压扁状态

由于

1 个答案:

答案 0 :(得分:1)

在您附加的日志中,在使HomeActivity膨胀时出错:

08-27 19:18:57.636: E/AndroidRuntime(19379): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.facebook.android.tomatosmasher/com.facebook.android.friendsmash.HomeActivity}: android.view.InflateException: Binary XML file line #24: Error inflating class fragment

当你旋转手机时会发生这种情况,因为那时活动被销毁并重新创建以允许不同的资源重新加载......

调查此方向并发布一些代码,以便我们为您提供更好的帮助。