java.lang.NullPointerException: Attempt to invoke virtual method 'android.support.v4.app.FragmentTransaction android.support.v4.app.FragmentTransaction.replace(int, android.support.v4.app.Fragment)' on a null object reference

Stack Overflow | EricHo | 4 months ago
tip
Click on the to mark the solution that helps you, Samebug will learn from it.
As a community member, you’ll be rewarded for you help.
  1. 0

    FragmentManager return null

    Stack Overflow | 4 months ago | EricHo
    java.lang.NullPointerException: Attempt to invoke virtual method 'android.support.v4.app.FragmentTransaction android.support.v4.app.FragmentTransaction.replace(int, android.support.v4.app.Fragment)' on a null object reference

    Root Cause Analysis

    1. java.lang.NullPointerException

      Attempt to invoke virtual method 'android.support.v4.app.FragmentTransaction android.support.v4.app.FragmentTransaction.replace(int, android.support.v4.app.Fragment)' on a null object reference

      at com.example.h6.personalfinancegidget.BaseFragmentForMonthPlan.getPlanMonthFragment()
    2. com.example.h6
      MonthlyPlanActivity$1.onPageSelected
      1. com.example.h6.personalfinancegidget.BaseFragmentForMonthPlan.getPlanMonthFragment(BaseFragmentForMonthPlan.java:39)
      2. com.example.h6.personalfinancegidget.MonthlyPlanActivity$1.onPageSelected(MonthlyPlanActivity.java:68)
      2 frames
    3. Android Support v4
      ViewPager.setCurrentItem
      1. android.support.v4.view.ViewPager.dispatchOnPageSelected(ViewPager.java:1939)
      2. android.support.v4.view.ViewPager.scrollToItem(ViewPager.java:687)
      3. android.support.v4.view.ViewPager.setCurrentItemInternal(ViewPager.java:671)
      4. android.support.v4.view.ViewPager.setCurrentItemInternal(ViewPager.java:632)
      5. android.support.v4.view.ViewPager.setCurrentItem(ViewPager.java:613)
      5 frames
    4. com.example.h6
      MonthlyPlanActivity$2.onTabSelected
      1. com.example.h6.personalfinancegidget.MonthlyPlanActivity$2.onTabSelected(MonthlyPlanActivity.java:82)
      1 frame
    5. android.support.design
      TabLayout$TabView.performClick
      1. android.support.design.widget.TabLayout.dispatchTabSelected(TabLayout.java:1149)
      2. android.support.design.widget.TabLayout.selectTab(TabLayout.java:1142)
      3. android.support.design.widget.TabLayout.selectTab(TabLayout.java:1112)
      4. android.support.design.widget.TabLayout$Tab.select(TabLayout.java:1407)
      5. android.support.design.widget.TabLayout$TabView.performClick(TabLayout.java:1511)
      5 frames
    6. Android Platform
      ActivityThread.main
      1. android.view.View$PerformClick.run(View.java:19866)
      2. android.os.Handler.handleCallback(Handler.java:739)
      3. android.os.Handler.dispatchMessage(Handler.java:95)
      4. android.os.Looper.loop(Looper.java:135)
      5. android.app.ActivityThread.main(ActivityThread.java:5254)
      5 frames
    7. Java RT
      Method.invoke
      1. java.lang.reflect.Method.invoke(Native Method)
      2. java.lang.reflect.Method.invoke(Method.java:372)
      2 frames
    8. Android
      ZygoteInit.main
      1. com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903)
      2. com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)
      2 frames