Elhanan Mishraky Elhanan Mishraky - 1 month ago 17
Android Question

android.support.v4.app.FragmentManager#popBackStackImmediate() results in a NullPointerException

Sometimes executing

android.support.v4.app.FragmentManager#popBackStackImmediate()
results in the next exception:

> Fatal Exception: java.lang.NullPointerException: Attempt to invoke
> virtual method 'android.os.Handler
> android.support.v4.app.FragmentHostCallback.getHandler()' on a null
> object reference
> at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1588)
> at android.support.v4.app.FragmentManagerImpl.executePendingTransactions(FragmentManager.java:570)
> at android.support.v4.app.FragmentManagerImpl.popBackStackImmediate(FragmentManager.java:585)


Here is my code:

FragmentManager manager = getSupportFragmentManager();
FragmentTransaction fragmentTransaction = manager.beginTransaction();
manager.popBackStackImmediate();
fragmentTransaction.commitAllowingStateLoss();


Does anyone knows what could be the reason for that?

Answer

I moved back from compile 'com.android.support:support-v4:23.1.1' to compile 'com.android.support:support-v4:23.1.0' and now it doesn't happen any more. So to conclude, it seems like there is a bug with support-v4:23.1.1.

Comments