Trying to remove fragment from view gives me NullPointerException on mNextAnim
Solution 1:
I know you've solved this yourself, but I want to explain how this error happens, since it just happened to me.
Basically you're calling hide()
, remove()
, etc., with a null value.
The error isn't obvious, and the stack trace doesn't originate from your own sources when this happens, so it's not trivial to realise what it is.
Solution 2:
It also happens when you call FragmentManager.popBackstack()
without there being a fragment in the backstack.
Solution 3:
this is because you add or show or hide a fragment which is null now,try to check if it is null ,before you use it!
Solution 4:
My problem was that FragmentManager's getFragments() sometimes returns a list where some fragments are null, and I was removing those null fragments.