FragmentManager is already executing transactions viewpager2

I am using 4 fragments with view pager 2. And got this error suddenly. The crash does not always appear. I have searched other problems but I could not find any solution about viewpager2.

crash report from mobile could not get the full picture

setUpViewPager() calling this from onStart() of MainActivity

public void setupViewPager() {
        MainActivityViewPager adapter = new MainActivityViewPager(getSupportFragmentManager(), getLifecycle());



        binding.viewpager.registerOnPageChangeCallback(new ViewPager2.OnPageChangeCallback() {
            public void onPageSelected(int position) {
                if (prevMenuItem != null) {
                } else {
                prevMenuItem = binding.bottomNavigation.getMenu().getItem(position);



public class MainActivityViewPager extends FragmentStateAdapter {

    public MainActivityViewPager(@NonNull FragmentManager fragmentManager, @NonNull Lifecycle lifecycle) {
        super(fragmentManager, lifecycle);

    public Fragment createFragment(int position) {
        switch (position) {
            case 0:
                return new HomeFragment();
            case 1:
                return new ProgressFragment();
            case 2:
                return new MoreFragment();
            case 3:
                return new ProfileFragment();
        return null;

    public int getItemCount() {
        return 4;

Can anyone suggest me a solution? This is currently happening in a production app and I have got red alert on my head. Thank you people


basing on log your ViewPager is placed inside (nested?) Fragment, so you should use getChildFragmentManager instead of getSupportFragmentManager