android – Crash in Activity Transitions with SharedElement-ThrowExceptions

Exception or error:

I’m using Activity transitions from a ViewPager (in the calling activity) with a shared element and content transitions as well. I’m getting this crash when re-entering to the calling activity:

java.lang.NullPointerException: Attempt to invoke virtual method 'void android.os.ResultReceiver.send(int, android.os.Bundle)' on a null object reference
  at android.view.ViewTreeObserver.dispatchOnPreDraw(
  at android.view.ViewRootImpl.performTraversals(
  at android.view.ViewRootImpl.doTraversal(
  at android.view.ViewRootImpl$
  at android.view.Choreographer$
  at android.view.Choreographer.doCallbacks(
  at android.view.Choreographer.doFrame(
  at android.view.Choreographer$
  at android.os.Handler.handleCallback(
  at android.os.Handler.dispatchMessage(
  at android.os.Looper.loop(
  at java.lang.reflect.Method.invoke(Native Method)
  at java.lang.reflect.Method.invoke(

Also, Once going back, the screen begins to flicker continuously with a white screen flashing in and out.

Here are my Transition flags:

<item name="android:windowContentTransitions">true</item>
<item name="android:windowActivityTransitions">true</item>
<item name="android:windowAllowReturnTransitionOverlap">false</item>

I tried setting Enter/Exit transitions both on the Calling and Called activity but no luck.

How to solve:

Try to get fragment from FragmentManager:

fragmentManager.findFragmentByTag("android:switcher:" + + ":" + position)

If fragment is null, try creating a new fragment.

Leave a Reply

Your email address will not be published. Required fields are marked *