我正在开发一个 Android 应用程序,并且在修改 Fragment 的代码时,现在每当我尝试启动该应用程序时都会遇到严重的崩溃。奇怪的是,NullPointerException 在它真正到达我的代码之前就被抛出,因为当我进入调试模式时,异常在我到达 MainActivity 的 OnCreate() 之前被抛出。特别令人费解的是,我并没有在 MainActivity 和它的布局中弄乱任何东西。
下面的堆栈跟踪。有任何想法吗?
07-30 15:39:52.753: E/AndroidRuntime(5348): FATAL EXCEPTION: main
07-30 15:39:52.753: E/AndroidRuntime(5348): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.legacy/com.example.legacy.MainActivity}: java.lang.NullPointerException
07-30 15:39:52.753: E/AndroidRuntime(5348): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2110)
07-30 15:39:52.753: E/AndroidRuntime(5348): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2135)
07-30 15:39:52.753: E/AndroidRuntime(5348): at android.app.ActivityThread.access$700(ActivityThread.java:143)
07-30 15:39:52.753: E/AndroidRuntime(5348): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1241)
07-30 15:39:52.753: E/AndroidRuntime(5348): at android.os.Handler.dispatchMessage(Handler.java:99)
07-30 15:39:52.753: E/AndroidRuntime(5348): at android.os.Looper.loop(Looper.java:137)
07-30 15:39:52.753: E/AndroidRuntime(5348): at android.app.ActivityThread.main(ActivityThread.java:4950)
07-30 15:39:52.753: E/AndroidRuntime(5348): at java.lang.reflect.Method.invokeNative(Native Method)
07-30 15:39:52.753: E/AndroidRuntime(5348): at java.lang.reflect.Method.invoke(Method.java:511)
07-30 15:39:52.753: E/AndroidRuntime(5348): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1004)
07-30 15:39:52.753: E/AndroidRuntime(5348): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:771)
07-30 15:39:52.753: E/AndroidRuntime(5348): at dalvik.system.NativeStart.main(Native Method)
07-30 15:39:52.753: E/AndroidRuntime(5348): Caused by: java.lang.NullPointerException
07-30 15:39:52.753: E/AndroidRuntime(5348): at android.support.v4.app.BackStackRecord.run(BackStackRecord.java:656)
07-30 15:39:52.753: E/AndroidRuntime(5348): at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1444)
07-30 15:39:52.753: E/AndroidRuntime(5348): at android.support.v4.app.Fragment.performStart(Fragment.java:1481)
07-30 15:39:52.753: E/AndroidRuntime(5348): at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:941)
07-30 15:39:52.753: E/AndroidRuntime(5348): at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1088)
07-30 15:39:52.753: E/AndroidRuntime(5348): at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1070)
07-30 15:39:52.753: E/AndroidRuntime(5348): at android.support.v4.app.FragmentManagerImpl.dispatchStart(FragmentManager.java:1866)
07-30 15:39:52.753: E/AndroidRuntime(5348): at android.support.v4.app.FragmentActivity.onStart(FragmentActivity.java:568)
07-30 15:39:52.753: E/AndroidRuntime(5348): at android.app.Instrumentation.callActivityOnStart(Instrumentation.java:1178)
07-30 15:39:52.753: E/AndroidRuntime(5348): at android.app.Activity.performStart(Activity.java:5189)
07-30 15:39:52.753: E/AndroidRuntime(5348): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2083)
提前致谢。