title: androidx data binding life cycle NullPointerException
body: <p>I cannot seem to find the origin of this <code>DataBinding</code> <code>NullPointerException</code>. While using <code>Android Navigation Architecture</code> when navigating to a <code>Fragment</code> and navigating up again repetitively I will eventually end up with the following stack trace</p>
  
  <pre><code>java.lang.NullPointerException: Attempt to invoke direct method 'void androidx.databinding.ViewDataBinding.handleFieldChange(int, java.lang.Object, int)' on a null object reference
          at androidx.databinding.ViewDataBinding.access$800(ViewDataBinding.java:64)
          at androidx.databinding.ViewDataBinding$LiveDataListener.onChanged(ViewDataBinding.java:1592)
          at androidx.lifecycle.LiveData.considerNotify(LiveData.java:113)
          at androidx.lifecycle.LiveData.dispatchingValue(LiveData.java:126)
          at androidx.lifecycle.LiveData$ObserverWrapper.activeStateChanged(LiveData.java:424)
          at androidx.lifecycle.LiveData$LifecycleBoundObserver.onStateChanged(LiveData.java:376)
          at androidx.lifecycle.LifecycleRegistry$ObserverWithState.dispatchEvent(LifecycleRegistry.java:355)
          at androidx.lifecycle.LifecycleRegistry.forwardPass(LifecycleRegistry.java:293)
          at androidx.lifecycle.LifecycleRegistry.sync(LifecycleRegistry.java:333)
          at androidx.lifecycle.LifecycleRegistry.moveToState(LifecycleRegistry.java:138)
          at androidx.lifecycle.LifecycleRegistry.handleLifecycleEvent(LifecycleRegistry.java:124)
          at androidx.fragment.app.Fragment.performStart(Fragment.java:2485)
          at androidx.fragment.app.FragmentManagerImpl.moveToState(FragmentManager.java:1494)
          at androidx.fragment.app.FragmentManagerImpl.addAddedFragments(FragmentManager.java:2646)
          at androidx.fragment.app.FragmentManagerImpl.executeOpsTogether(FragmentManager.java:2416)
          at androidx.fragment.app.FragmentManagerImpl.removeRedundantOperationsAndExecute(FragmentManager.java:2372)
          at androidx.fragment.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:2273)
          at androidx.fragment.app.FragmentManagerImpl$1.run(FragmentManager.java:733)
          at android.os.Handler.handleCallback(Handler.java:789)
          at android.os.Handler.dispatchMessage(Handler.java:98)
          at android.os.Looper.loop(Looper.java:164)
          at android.app.ActivityThread.main(ActivityThread.java:6938)
          at java.lang.reflect.Method.invoke(Native Method)
          at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:327)
          at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1374)
  </code></pre>
  
  <p>It looks like it has something to do with the <code>LiveData</code> lifecycle as stated in the exception. I'm guessing <code>onPause</code> the <code>LiveData</code> objects in the <code>ViewModel</code> are cleared for memory sake and are then for some reason accessed again.</p>
  
  <p>This seems to be very random as it happens on all of our fragments but only when continuously navigating to and from that specific fragment or between different fragments in the app. We don't attempt to access <code>LiveData</code> objects after the fragment is paused/destroyed. I have not been able to find anyone who has experienced this problem before, and find it quite difficult to get to the root of the issue. </p>