Exception android.content.res.Resources$NotFoundException: File res/color/selector_tab_blue_white.xml from drawable resource ID #0x7f0601d8

こ雲淡風輕ζ 提交于 2020-05-17 05:55:06

问题


I am using tabLayout as

  <com.google.android.material.tabs.TabLayout
                    android:id="@+id/tabLayoutSubscriptionDays"
                    style="@style/CustomTabLayoutTextSizeSix"
                    android:layout_width="match_parent"
                    android:layout_height="@dimen/_40sdp"
                    android:background="@color/white"
                    app:tabBackground="@color/selector_tab_blue_white"
                    app:tabIndicatorColor="@color/transparent"
                    app:tabMode="fixed"
                    app:tabSelectedTextColor="@color/white"
                    app:tabTextColor="@color/black" />

In some devices i am getting exception as like : android.content.res.Resources$NotFoundException: File res/color/selector_tab_blue_white.xml from drawable resource ID #0x7f0601d8

This is my selector which is in color directory:

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:color="@color/blue_4880ff" android:state_selected="true" />
<item android:color="@color/white" />
</selector>

I have tried so many solutions regarding this like:

  defaultConfig {
    vectorDrawables.useSupportLibrary = true
}

AppCompatDelegate.setCompatVectorFromResourcesEnabled(true)

These solutions I have tried.

If anyone can help then it will be so good. Thanks


回答1:


You have to add that drawable file in 2 folders along with drawable folder:

drawable
drawable-v24

Then it will not crash on any device.

Hope this helps




回答2:


Please Follow below steps to resolve this issue ..

  1. first check this file is present in project or not
  2. now sync your gradle
  3. Click on clean project
  4. Click on Rebuild project
  5. Invalidate Caches/Restart
  6. Re-run project


来源:https://stackoverflow.com/questions/61651613/exception-android-content-res-resourcesnotfoundexception-file-res-color-select

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!