FragmentManager IllegalStateException: No host
<p><strong>UPDATE</strong>:
Crashes gone when i put nullcheks (fragment != null, getActivity() != null) whereever i could.</p>

<p>My app is using <strong>ViewPager</strong> (offscreen limit 5) with <strong>FragmentStatePagerAdapter</strong> initialized with <strong>getSupportFragmentManager()</strong>. Each page has it's own fragments and backstack.</p>

<p>App crashes on startup. Problem occurs only on <strong>preLollipop</strong> devices and emulator. Using latest support lbrary (tried 24.0.0 also - same result)
Stacktrace:</p>

<blockquote>
  <p>java.lang.IllegalStateException: No host at
  android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1273)
                                                                             at
  android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1268)
                                                                             at
  android.support.v4.app.FragmentManagerImpl.dispatchCreate(FragmentManager.java:2138)
                                                                             at android.support.v4.app.Fragment.onCreate(Fragment.java:1254)
                                                                             at android.support.v4.app.Fragment.performCreate(Fragment.java:2062)
                                                                             at
  android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1051)
                                                                             at
  android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1286)
                                                                             at
  android.support.v4.app.BackStackRecord.run(BackStackRecord.java:758)
                                                                             at
  android.support.v4.app.FragmentManagerImpl.execSingleAction(FragmentManager.java:1632)
                                                                             at
  android.support.v4.app.BackStackRecord.commitNowAllowingStateLoss(BackStackRecord.java:637)
                                                                             at
  android.support.v4.app.FragmentStatePagerAdapter.finishUpdate(FragmentStatePagerAdapter.java:166)
                                                                             at android.support.v4.view.ViewPager.populate(ViewPager.java:1237)
                                                                             at android.support.v4.view.ViewPager.populate(ViewPager.java:1085)
                                                                             at android.support.v4.view.ViewPager.onMeasure(ViewPager.java:1611)
                                                                             at android.view.View.measure(View.java:16497)
                                                                             at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5125)
                                                                             at
  android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1404)
                                                                             at android.widget.LinearLayout.measureVertical(LinearLayout.java:695)
                                                                             at android.widget.LinearLayout.onMeasure(LinearLayout.java:588)
                                                                             at android.view.View.measure(View.java:16497)
                                                                             at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5125)
                                                                             at android.widget.FrameLayout.onMeasure(FrameLayout.java:310)
                                                                             at android.view.View.measure(View.java:16497)
                                                                             at
  android.widget.RelativeLayout.measureChildHorizontal(RelativeLayout.java:719)
                                                                             at android.widget.RelativeLayout.onMeasure(RelativeLayout.java:455)
                                                                             at android.view.View.measure(View.java:16497)
                                                                             at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5125)
                                                                             at android.widget.FrameLayout.onMeasure(FrameLayout.java:310)
                                                                             at
  android.support.v7.widget.ContentFrameLayout.onMeasure(ContentFrameLayout.java:135)
                                                                             at android.view.View.measure(View.java:16497)
                                                                             at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5125)
                                                                             at android.widget.FrameLayout.onMeasure(FrameLayout.java:310)
                                                                             at android.view.View.measure(View.java:16497)
                                                                             at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5125)
                                                                             at android.widget.FrameLayout.onMeasure(FrameLayout.java:310)
                                                                             at android.view.View.measure(View.java:16497)
                                                                             at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5125)
                                                                             at
  android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1404)
                                                                             at android.widget.LinearLayout.measureVertical(LinearLayout.java:695)
                                                                             at android.widget.LinearLayout.onMeasure(LinearLayout.java:588)
                                                                             at android.view.View.measure(View.java:16497)
                                                                             at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5125)
                                                                             at android.widget.FrameLayout.onMeasure(FrameLayout.java:310)
                                                                             at
  com.android.internal.policy.impl.PhoneWindow$DecorView.onMeasure(PhoneWindow.java:2291)
                                                                             at android.view.View.measure(View.java:16497)
                                                                             at android.view.ViewRootImpl.performMeasure(ViewRootImpl.java:1912)
                                                                             at android.view.ViewRootImpl.measureHierarchy(ViewRootImpl.java:1109)
                                                                             at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1291)
                                                                             at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:996)
                                                                             at
  android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:5600)
                                                                             at
  android.view.Choreographer$CallbackRecord.run(Choreographer.java:761)
                                                                             at android.view.Choreographer.doCallbacks(Choreographer.java:574)
                                                                             at android.view.Choreographer.doFrame(Choreographer.java:544)
                                                                             at
  android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:747)
                                                                             at android.os.Handler.handleCallback(Handler.java:733)
                                                                             at android.os.Handler.dispatchMessage(Handler.java:95)
                                                                             at android.os.Looper.loop(Looper.java:136)</p>
</blockquote>