致命异常:java.lang.RuntimeException:无法启动Activity

时间:2016-02-03 07:08:32

标签: android-fragments nullpointerexception runtimeexception android-runtime

嘿,我是Android工作室的新人,帮我解决问题。我使用ActionBarSherlock库,它在用户暂停应用程序时保存当前Fragment实例的引用。

Fatal Exception: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.maruticourier.android/com.myapplication.activity.MainActivity}: java.lang.NullPointerException
   at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2266)
   at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2316)
   at android.app.ActivityThread.access$600(ActivityThread.java:150)
   at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1298)
   at android.os.Handler.dispatchMessage(Handler.java:99)
   at android.os.Looper.loop(Looper.java:213)
   at android.app.ActivityThread.main(ActivityThread.java:5225)
   at java.lang.reflect.Method.invokeNative(Method.java)
   at java.lang.reflect.Method.invoke(Method.java:525)
   at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:741)
   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:557)
   at dalvik.system.NativeStart.main(NativeStart.java)
   Caused by java.lang.NullPointerException**
   at com.myapplication.fragment.PendingTask.checksyncdata(PendingTask.java:378)
   at com.myapplication.fragment.PendingTask.onCreateView(PendingTask.java:182)
   at android.support.v4.app.Fragment.performCreateView(Fragment.java:1786)
   at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:947)
   at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1126)
   at android.support.v4.app.BackStackRecord.run(BackStackRecord.java:739)
   at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1489)
   at android.support.v4.app.FragmentActivity.onStart(FragmentActivity.java:548)
   at android.app.Instrumentation.callActivityOnStart(Instrumentation.java:1171)
   at android.app.Activity.performStart(Activity.java:5143)
   at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2239)
   at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2316)
   at android.app.ActivityThread.access$600(ActivityThread.java:150)
   at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1298)
   at android.os.Handler.dispatchMessage(Handler.java:99)
   at android.os.Looper.loop(Looper.java:213)
   at android.app.ActivityThread.main(ActivityThread.java:5225)
   at java.lang.reflect.Method.invokeNative(Method.java)
   at java.lang.reflect.Method.invoke(Method.java:525)
   at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:741)
   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:557)
   at dalvik.system.NativeStart.main(NativeStart.java)

1 个答案:

答案 0 :(得分:1)

您必须初始化Activity Object ActionBarSherlock项目文件