title: Invalid ID 0x00000001 errors after ViewPager2 migration
body: <p>I have been working with a Tab layout with ViewPager for a while and it has gone deprecated.
  I followed the official documentation and migrated to ViewPager2,
  everything works but I am getting the following error on each fragment:</p>
  <p>Invalid ID 0x00000001
  Invalid ID 0x00000001
  Invalid ID 0x00000001</p>
  <p>And these will increase each time I slide between fragments..
  No crash but every time I re-open the activity the number increases to Invalid ID 0x00000002 and so on.</p>
  <p>I am lost with solutions to get this error away, but the app still works with the new ViewPager2.
  Any idea's to solve the error spam messages?</p>
  <p>Activity code:</p>
  <pre><code>//Responsible for adding the 4 tabs: NewLoot, ActiveLoot, SharedLoot, FinishedLoot
      private void setupViewPager(){
          SectionsPagerAdapter adapter = new SectionsPagerAdapter(getSupportFragmentManager(),getLifecycle());
          adapter.addFragment(new NewLootFragment());//index 0
          adapter.addFragment(new ActiveLootFragment());//index 1
          adapter.addFragment(new FinishedLootFragment());//index 2
          ViewPager2 viewPager = (ViewPager2) findViewById(R.id.container);
          viewPager.setAdapter(adapter);
          final TabLayout tabLayout = (TabLayout) findViewById(R.id.tab_layout);
          new TabLayoutMediator(tabLayout, viewPager,
                  new TabLayoutMediator.TabConfigurationStrategy() {
                      @Override
                      public void onConfigureTab(@NonNull TabLayout.Tab tab, int position) {
                          //tab.setText(&quot;OBJECT &quot; + (position + 1));
                      }
                  }
          ).attach();
          tabLayout.getTabAt(0).setIcon(R.drawable.ic_search);
          tabLayout.getTabAt(1).setIcon(R.drawable.ic_arrow);
          tabLayout.getTabAt(2).setIcon(R.drawable.ic_action_name);
  
          tabLayout.getTabAt(0).getIcon().setColorFilter(getResources().getColor(R.color.red), PorterDuff.Mode.SRC_IN);
          tabLayout.getTabAt(1).getIcon().setColorFilter(getResources().getColor(android.R.color.black), PorterDuff.Mode.SRC_IN);
          tabLayout.getTabAt(2).getIcon().setColorFilter(getResources().getColor(android.R.color.black), PorterDuff.Mode.SRC_IN);
  
          tabLayout.addOnTabSelectedListener(new TabLayout.OnTabSelectedListener() {
              @Override
              public void onTabSelected(TabLayout.Tab tab) {
                  tab.view.getTab().getIcon().setColorFilter(getResources().getColor(R.color.red), PorterDuff.Mode.SRC_IN);
              }           @Override
              public void onTabUnselected(TabLayout.Tab tab) {
                  tab.view.getTab().getIcon().setColorFilter(getResources().getColor(android.R.color.black), PorterDuff.Mode.SRC_IN);
              }           @Override
              public void onTabReselected(TabLayout.Tab tab) {
              }
          });
  
      }
  </code></pre>
  <p>SectionPagerAdapter code:</p>
  <pre><code>//Class that stores fragments for tabs
  public class SectionsPagerAdapter extends FragmentStateAdapter {
      private static String TAG = &quot;SectionsPagerAdapter&quot;;
  
      private final ArrayList&lt;Fragment&gt; mFragmentList = new ArrayList&lt;&gt;();
  
      public SectionsPagerAdapter(@NonNull FragmentManager fragmentManager, @NonNull Lifecycle lifecycle){
          super(fragmentManager, lifecycle);
      }
  
      //public ViewPagerFragmentAdapter(@NonNull FragmentManager fragmentManager, @NonNull Lifecycle lifecycle) {
      //    super(fragmentManager, lifecycle);
      //}
  
      public void addFragment(Fragment fragment){
          mFragmentList.add(fragment);
      }
  
      @NonNull
      @Override
      public Fragment createFragment(int position) {
          return mFragmentList.get(position);
      }
  
      @Override
      public int getItemCount() {
          return mFragmentList.size();
      }
  }
  </code></pre>
  <p>Layout activity:</p>
  <pre><code>&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
  &lt;androidx.constraintlayout.widget.ConstraintLayout xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;
      xmlns:tools=&quot;http://schemas.android.com/tools&quot;
      android:layout_width=&quot;match_parent&quot;
      android:layout_height=&quot;match_parent&quot;
      tools:context=&quot;.Loot.LootActivity&quot;&gt;
  
      &lt;RelativeLayout
          android:layout_width=&quot;match_parent&quot;
          android:layout_height=&quot;match_parent&quot;&gt;
  
          &lt;!-- Top Section (Toolbar) --&gt;
          &lt;RelativeLayout
              android:layout_width=&quot;match_parent&quot;
              android:layout_height=&quot;wrap_content&quot;
              android:id=&quot;@+id/relLayout0&quot;&gt;
  
              &lt;include
                  android:id=&quot;@+id/topViewBarHelper&quot;
                  layout=&quot;@layout/snippet_top_profilebar&quot;
                  android:layout_width=&quot;match_parent&quot;
                  android:layout_height=&quot;wrap_content&quot;/&gt;
  
          &lt;/RelativeLayout&gt;
  
          &lt;!-- Top Section (Toolbar) --&gt;
          &lt;RelativeLayout
              android:layout_width=&quot;match_parent&quot;
              android:layout_height=&quot;wrap_content&quot;
              android:id=&quot;@+id/relLayout1&quot;
              android:layout_below=&quot;@+id/relLayout0&quot;&gt;
  
              &lt;include layout=&quot;@layout/layout_top_tabs&quot;/&gt;
  
          &lt;/RelativeLayout&gt;
  
          &lt;!-- Middle Section (Body) --&gt;
          &lt;RelativeLayout
              android:layout_width=&quot;match_parent&quot;
              android:layout_height=&quot;wrap_content&quot;
              android:id=&quot;@+id/relLayout2&quot;
              android:layout_below=&quot;@+id/relLayout1&quot;&gt;
  
              &lt;include layout=&quot;@layout/layout_center_viewpager&quot;/&gt;
  
          &lt;/RelativeLayout&gt;
  
          &lt;RelativeLayout
              android:layout_width=&quot;match_parent&quot;
              android:layout_height=&quot;wrap_content&quot;
              android:id=&quot;@+id/relLayout3&quot;&gt;
  
              &lt;!-- Bottom Section (Navigation) --&gt;
              &lt;include layout=&quot;@layout/layout_bottom_navigation_view&quot;/&gt;
  
          &lt;/RelativeLayout&gt;
  
      &lt;/RelativeLayout&gt;
  &lt;/androidx.constraintlayout.widget.ConstraintLayout&gt;
  </code></pre>
  <p>layout center viewpager:</p>
  <pre><code>&lt;merge xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;
      xmlns:app=&quot;http://schemas.android.com/apk/res-auto&quot;&gt;
  
      &lt;RelativeLayout
          android:layout_width=&quot;match_parent&quot;
          android:layout_height=&quot;match_parent&quot;&gt;
          
          &lt;androidx.viewpager2.widget.ViewPager2
              android:id=&quot;@+id/container&quot;
              android:layout_width=&quot;match_parent&quot;
              android:layout_height=&quot;match_parent&quot;
              android:layoutDirection=&quot;ltr&quot;&gt;
          &lt;/androidx.viewpager2.widget.ViewPager2&gt;
  
      &lt;/RelativeLayout&gt;
  
  &lt;/merge&gt;
  </code></pre>
  <p>layout top tabs:</p>
  <pre><code>&lt;merge xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;
      xmlns:app=&quot;http://schemas.android.com/apk/res-auto&quot;&gt;
  
      &lt;RelativeLayout
          android:layout_width=&quot;match_parent&quot;
          android:layout_height=&quot;50dp&quot;
          android:layout_alignParentTop=&quot;true&quot;&gt;
  
          &lt;com.google.android.material.appbar.AppBarLayout
              android:layout_width=&quot;match_parent&quot;
              android:layout_height=&quot;match_parent&quot;
              android:id=&quot;@+id/AppBarLayout&quot;&gt;
  
              &lt;com.google.android.material.tabs.TabLayout
                  android:layout_width=&quot;match_parent&quot;
                  android:layout_height=&quot;match_parent&quot;
                  android:id=&quot;@+id/tab_layout&quot;
                  android:background=&quot;@drawable/white_grey_border_bottom&quot;
                  app:tabIndicatorColor=&quot;@color/red&quot;
                  app:tabIndicatorHeight=&quot;4dp&quot;&gt;
              &lt;/com.google.android.material.tabs.TabLayout&gt;
  
          &lt;/com.google.android.material.appbar.AppBarLayout&gt;
  
      &lt;/RelativeLayout&gt;
  
  &lt;/merge&gt;
  </code></pre>