material-components-android icon indicating copy to clipboard operation
material-components-android copied to clipboard

[TabLayout] ResourcesNotFoundException "res/layout/design_layout_tab_icon.xml" when setting ViewPager adapter

Open waseefakhtar opened this issue 3 years ago • 2 comments
trafficstars

Description:

We exprienced a crashe in production related to TabLayout when setting ViewPager adapter from Motorola running Android 11. I wonder if you're aware of the issue and if there's any fix.

Fatal Exception: android.content.res.Resources$NotFoundException: File res/layout/design_layout_tab_icon.xml from xml type layout resource ID #0x7f0d0071
       at android.content.res.ResourcesImpl.loadXmlResourceParser(ResourcesImpl.java:1277)
       at android.content.res.Resources.loadXmlResourceParser(Resources.java:2426)
       at android.content.res.Resources.loadXmlResourceParser(Resources.java:2402)
       at android.content.res.Resources.getLayout(Resources.java:1252)
       at android.view.LayoutInflater.inflate(LayoutInflater.java:530)
       at com.google.android.material.tabs.TabLayout$TabView.inflateAndAddDefaultIconView(TabLayout.java:2659)
       at com.google.android.material.tabs.TabLayout$TabView.update(TabLayout.java:2608)
       at com.google.android.material.tabs.TabLayout$TabView.setTab(TabLayout.java:2561)
       at com.google.android.material.tabs.TabLayout.createTabView(TabLayout.java:1554)
       at com.google.android.material.tabs.TabLayout.newTab(TabLayout.java:859)
       at com.google.android.material.tabs.TabLayout.populateFromPagerAdapter(TabLayout.java:1529)
       at com.google.android.material.tabs.TabLayout.setPagerAdapter(TabLayout.java:1520)
       at com.google.android.material.tabs.TabLayout$AdapterChangeListener.onAdapterChanged(TabLayout.java:3440)
       at androidx.viewpager.widget.ViewPager.setAdapter(ViewPager.java:549)

Android API version: Android 11

Material Library version: 1.3.0

Device: Motorola

waseefakhtar avatar Sep 12 '22 12:09 waseefakhtar

Hi there, I'm not seeing this issue in our Catalog app, although I don't have a Motorola device or emulator so that could be why. Could you please provide some sample code to help us reproduce the crash? Also, have you verified that this issue doesn't happen on other devices/emulators?

afohrman avatar Sep 12 '22 16:09 afohrman

Hi there, I'm not seeing this issue in our Catalog app, although I don't have a Motorola device or emulator so that could be why. Could you please provide some sample code to help us reproduce the crash? Also, have you verified that this issue doesn't happen on other devices/emulators?

We have yet to roll out the release with the issue completely, so to verify whether this happen on other devices, we'll have to wait until we have more data. One things to note is that we haven't updated any related dependencies that has led to this issue which only started happening in the latest release.

It's a very simple implementation of a ViewPager that caused it:

        <androidx.viewpager.widget.ViewPager
            android:id="@+id/view_pager_detail_root"
            android:layout_width="0dp"
            android:layout_height="0dp"
            android:layout_marginTop="15dp"
            app:layout_constraintBottom_toBottomOf="parent"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toBottomOf="@+id/tab_layout" />
    @Override
    public void onActivityCreated(@Nullable Bundle savedInstanceState) {
        super.onActivityCreated(savedInstanceState);

        mViewPagerAdapter = new CustomPagerAdapter(getChildFragmentManager());

        mBinding.viewPagerDetailRoot.setAdapter(mViewPagerAdapter);
    }

ViewPager Library version: 1.0.0

waseefakhtar avatar Sep 13 '22 06:09 waseefakhtar

Can you try to upgrade to the latest version of the Material library and see if it's still happening?

drchen avatar Sep 29 '22 20:09 drchen

I'll close this issue for now due to no further info available. Please feel free to reopen it if this is still happening.

drchen avatar Nov 16 '22 21:11 drchen