Crash with setnextanim?

Looking at the exception:

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

and the fact that the stack trace contains no references to your code, I think it is reasonable to assume it is not related to this part of your code.

Rather, it is possibly related to some view being garbage collected/nulled somewhere down the line and then trying to use it later, calling show/hide or similar on a null object. See this discussion.


In my case I removed a null fragment from stack:

val fragment = getSelectedFragment() // null
supportFragmentManager?.beginTransaction()
    ?.remove(fragment)
    ?.commit()