0

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

我添加了以下堆栈跟踪

该应用程序基于 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旋转时保持破碎

谢谢

4

1 回答 1

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

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

朝这个方向进行调查并发布一些代码,以便我们可以更好地帮助您。

于 2013-08-27T16:40:07.760 回答