Error inflating class android.support.design.widget.NavigationView

AndroidAndroid Support-LibraryAndroiddesignsupport

Android Problem Overview


I followed a tutorial of new component NavigationView in Support Design Library and can't get through this error message :

Error inflating class android.support.design.widget.NavigationView

I tried every workaround here

https://stackoverflow.com/questions/30547323/error-when-using-any-android-design-support-library-elements

but error message still exists.

###xml

<android.support.v4.widget.DrawerLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:id="@+id/drawer_layout"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fitsSystemWindows="true" >
    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent" >

    <include layout="@layout/toolbar" android:id="@+id/mainToolBar" />

    <fragment android:name="com.ais.cherry.fragment.LoginFragment"
        android:id="@+id/loginFragment"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_below="@id/mainToolBar" />
    <fragment     android:name="com.ais.cherry.fragment.WaterFallFragment"
        android:id="@+id/mainFragment"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_below="@id/mainToolBar" />
    <fragment android:name="com.ais.cherry.fragment.SearchFragment"
        android:id="@+id/searchFragment"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_below="@id/mainToolBar" />
    <fragment android:name="com.ais.cherry.fragment.ChatMainFragment"
        android:id="@+id/chatMainFragment"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_below="@id/mainToolBar" />
    <fragment android:name="com.ais.cherry.fragment.ProfileFragment"
        android:id="@+id/profileFragment"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_below="@id/mainToolBar" />


    <android.support.design.widget.NavigationView
        android:id="@+id/nav_view"
        android:layout_width="240dp"
        android:layout_height="match_parent"
        android:layout_gravity="start"
        android:background="@android:color/white"
        app:itemTextColor="#212121"
        app:headerLayout="@layout/drawer_header"
        app:menu="@menu/drawer" />
</android.support.v4.widget.DrawerLayout>

###build.gradle

buildscript {
    repositories {
        mavenCentral()
        maven { url 'https://maven.fabric.io/public' }
    }

    dependencies {
        classpath 'io.fabric.tools:gradle:1.+'
        classpath 'com.android.tools.build:gradle:1.2.3'
    }
}

compileSdkVersion 22
buildToolsVersion "22.0.1"

defaultConfig {
    applicationId "com.ais.cherry"
    minSdkVersion 16
    targetSdkVersion 22      
    multiDexEnabled true
    renderscriptTargetApi 22
    renderscriptSupportModeEnabled true

}
dependencies {
    compile 'com.android.support:appcompat-v7:22.2.0'
    compile 'com.android.support:support-v4:22.2.0'
    compile 'com.android.support:design:22.2.0'
    compile 'com.android.support:recyclerview-v7:22.2.0'
}

###Project build.gradle

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:1.2.3'
    }
}

###styles.xml

<?xml version="1.0" encoding="utf-8"?>

<!-- Base application theme. -->
<style name="AppTheme" parent="AppTheme.Base">

</style>

<style name="AppTheme.Base" parent="Theme.AppCompat.Light.NoActionBar">
    <item name="android:windowActionBarOverlay">true</item>
    <item name="android:windowActionModeOverlay">true</item>
    <item name="android:actionModeStyle">@style/AppTheme.ActionModeStyle</item>
    <item name="android:windowActionBar">false</item>
    <item name="windowActionBar">false</item>
    <item name="windowNoTitle">true</item>
    <item name="android:windowNoTitle">true</item>
    <!-- Support library compatibility -->
    <item name="windowActionBarOverlay">true</item>

    <!-- ActionBar color -->
    <item name="colorPrimary">#E91E63</item>
    <!-- Status bar color -->
    <item name="colorPrimaryDark">#C2185B</item>
    <!-- Window color -->
    <item name="android:windowBackground">@color/white</item>
    <!-- ActionBar title text -->
    <item name="android:titleTextStyle">@style/AppTheme.MyActionBarTitleText</item>

    <item name="colorAccent">#9E9E9E</item>

    <item name="drawerArrowStyle">@style/AppTheme.MyDrawerArrowStyle</item>

    <!-- color for actionMenu-->
    <item name="actionMenuTextColor">#FFFFFF</item>
    <item name="android:actionMenuTextColor">#FFFFFF</item>
    <!-- android:textColorSecondary is the color of the menu
   overflow icon (three vertical dots) -->
    <item name="android:textColorPrimary">#212121</item>
    <item name="android:textColorSecondary">#FFFFFF</item>
    <!--Navigation bar color-->
    <item name="android:navigationBarColor">#E91E63</item>
    <!--Status bar color-->
    <item name="android:statusBarColor">#C2185B</item>
</style>

Any help would be appreciated!

##Edit -- add @menu/drawer & @menu/drawer_header & stacktrace

###drawer.xml

<menu xmlns:android="http://schemas.android.com/apk/res/android">
    <group android:checkableBehavior="single">
        <item
            android:id="@+id/nav_first_fragment"
            android:icon="@drawable/home_view"
            android:checked="true"
            android:title="@string/main"/>
        <item
            android:id="@+id/nav_second_fragment"
            android:icon="@drawable/comment_view"
            android:title="@string/chat"/>
        <item
            android:id="@+id/nav_third_fragment"
            android:icon="@drawable/user_view"
            android:title="@string/profile"/>
        <item android:title="@string/search">
            <menu>
                <item
                    android:title="@string/clothes"/>
                <item
                    android:title="@string/pants"/>
            </menu>
        </item>
    </group>
</menu>

###drawer_header.xml

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical" android:layout_width="match_parent"
    android:layout_height="192dp"
    android:background="?attr/colorPrimaryDark"
    android:padding="16dp"
    android:theme="@style/ThemeOverlay.AppCompat.Dark"
    android:gravity="bottom">
    <TextView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="@string/title"
        android:textColor="@android:color/white"
            android:textAppearance="@style/TextAppearance.AppCompat.Body1"/>
</LinearLayout>
StackTrace (only part of them)

It thrown out three exceptions as below : all points out that the problems is caused by the line of "setContentView(layout)" at in layout.xml.

java.lang.RuntimeException: Unable to start activity  ComponentInfo{com.ais.cherry/com.ais.cherry.activity.FirstActivity}:    android.view.InflateException: Binary XML file line #32: Error inflating    class android.support.design.widget.NavigationView

Caused by: android.view.InflateException: Binary XML file line #32: Error inflating class android.support.design.widget.NavigationView

Caused by: java.lang.reflect.InvocationTargetException

Caused by: android.content.res.Resources$NotFoundException: Resource ID #0x0

Android Solutions


Solution 1 - Android

Actually it is not the matter of the primarycolortext, upgrading or downgrading the dependencies.This problem will likely occur when the version of your appcompat library and design support library doesn't match.

Example of matching condition

compile 'com.android.support:appcompat-v7:23.1.1' // appcompat library
compile 'com.android.support:design:23.1.1'       //design support library

Solution 2 - Android

I had similar error. When i use

<style name="AppTheme.Base" parent="Theme.AppCompat.Light.NoActionBar">

    <item name="colorPrimary">#673AB7</item>
    <item name="colorPrimaryDark">#512DA8</item>
    <item name="colorAccent">#00BCD4</item>
    <item name="android:textColorPrimary">#212121</item>
    <item name="android:textColorSecondary">#727272</item>

</style>

works for me when i remove the android:textColorPrimary and android:textColorSecondary theme items.

<style name="AppTheme.Base" parent="Theme.AppCompat.Light.NoActionBar">

    <item name="colorPrimary">#673AB7</item>
    <item name="colorPrimaryDark">#512DA8</item>
    <item name="colorAccent">#00BCD4</item>

</style>

Try working with a very simple App theme to start off with.

EDIT:

This [tutorial][1] will help. My understanding is that using "android:textColorPrimary" requires minimum api level 21. Using the same tag without "android:" uses the design support library. Any support library widget will try to find the "textColorPrimary" item instead of "android:textColorPrimary" and if it fails to find the same it throws the above mentioned error.

[1]: http://www.sitepoint.com/material-design-android-design-support-library/ "tutorial"

Solution 3 - Android

I also had same error. In my case some of the resources were in drawable-v21 only. Copy those resources to drawable folder also. This solved the issue for me.

Caused by: android.content.res.Resources$NotFoundException: Resource ID #0x0 

This is the main problem.

Solution 4 - Android

If you have already migrated to androidx, you should change your layout xml from

<android.support.design.widget.NavigationView ... />

to

<com.google.android.material.navigation.NavigationView ... />

Solution 5 - Android

I had the same error, I resolved it by adding app:itemTextColor="@color/a_color" to my navigation view :

<android.support.design.widget.NavigationView
    android:id="@+id/navigation_view"
    android:layout_width="wrap_content"
    android:layout_height="match_parent"
    android:layout_gravity="left"
    app:headerLayout="@layout/layout_drawer_header"
    app:menu="@menu/drawer_menu"
    app:itemTextColor="@color/primary"/>

You can still use android:textColorPrimary and android:textColorSecondary in your theme with this method.

Solution 6 - Android

Well So I was trying to fix this error. And none worked for me. I was not able to figure out solution. Scenario:

I was just going to made a Navigation Drawer Project inside Android Studio 2.1.2 And when I try to change the default Android icon in nav_header_main.xml I was getting some weird errors. I figured out that I was droping my PNG logo into the ...\app\src\main\res\drawable-21. When I try to put my PNG logo in ...\app\src\main\res\drawable bam! All weird errors go away.

Following are some of stack trace when I was putting PNG into drawable-21 folder:

08-17 17:29:56.237 6644-6678/myAppName  E/dalvikvm: Could not find class 'android.util.ArrayMap', referenced from method com.android.tools.fd.runtime.Restarter.getActivities
08-17 17:30:01.674 6644-6644/myAppName E/AndroidRuntime: FATAL EXCEPTION: main
                                                                         java.lang.RuntimeException: Unable to start activity ComponentInfo{myAppName.MainActivity}: android.view.InflateException: Binary XML file line #16: Error inflating class <unknown>
                                                                             at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2372)
                                                                             at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2424)
                                                                             at android.app.ActivityThread.handleRelaunchActivity(ActivityThread.java:3956)
                                                                             at android.app.ActivityThread.access$700(ActivityThread.java:169)
                                                                             at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1394)
                                                                             at android.os.Handler.dispatchMessage(Handler.java:107)
                                                                             at android.os.Looper.loop(Looper.java:194)
                                                                             at android.app.ActivityThread.main(ActivityThread.java:5433)
                                                                             at java.lang.reflect.Method.invokeNative(Native Method)
                                                                             at java.lang.reflect.Method.invoke(Method.java:525)
                                                                             at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:924)
                                                                             at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:691)
                                                                             at dalvik.system.NativeStart.main(Native Method)
                                                                          Caused by: android.view.InflateException: Binary XML file line #16: Error inflating class <unknown>
                                                                             at android.view.LayoutInflater.createView(LayoutInflater.java:613)
                                                                             at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:687)
                                                                             at android.view.LayoutInflater.rInflate(LayoutInflater.java:746)
                                                                             at android.view.LayoutInflater.inflate(LayoutInflater.java:489)
                                                                             at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
                                                                             at android.view.LayoutInflater.inflate(LayoutInflater.java:352)
                                                                             at android.support.v7.app.AppCompatDelegateImplV7.setContentView(AppCompatDelegateImplV7.java:280)
                                                                             at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:140)
                                                                             at edu.uswat.fwd82.findmedoc.MainActivity.onCreate(MainActivity.java:22)
                                                                             at android.app.Activity.performCreate(Activity.java:5179)
                                                                             at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1146)
                                                                             at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2336)
                                                                             at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2424) 
                                                                             at android.app.ActivityThread.handleRelaunchActivity(ActivityThread.java:3956) 
                                                                             at android.app.ActivityThread.access$700(ActivityThread.java:169) 
                                                                             at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1394) 
                                                                             at android.os.Handler.dispatchMessage(Handler.java:107) 
                                                                             at android.os.Looper.loop(Looper.java:194) 
                                                                             at android.app.ActivityThread.main(ActivityThread.java:5433) 
                                                                             at java.lang.reflect.Method.invokeNative(Native Method) 
                                                                             at java.lang.reflect.Method.invoke(Method.java:525) 
                                                                             at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:924) 
                                                                             at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:691) 
                                                                             at dalvik.system.NativeStart.main(Native Method) 
                                                                          Caused by: java.lang.reflect.InvocationTargetException
                                                                             at java.lang.reflect.Constructor.constructNative(Native Method)
                                                                             at java.lang.reflect.Constructor.newInstance(Constructor.java:417)
                                                                             at android.view.LayoutInflater.createView(LayoutInflater.java:587)
                                                                             at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:687) 
                                                                             at android.view.LayoutInflater.rInflate(LayoutInflater.java:746) 
                                                                             at android.view.LayoutInflater.inflate(LayoutInflater.java:489) 
                                                                             at android.view.LayoutInflater.inflate(LayoutInflater.java:396) 
                                                                             at android.view.LayoutInflater.inflate(LayoutInflater.java:352) 
                                                                             at android.support.v7.app.AppCompatDelegateImplV7.setContentView(AppCompatDelegateImplV7.java:280) 
                                                                             at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:140) 
                                                                             at edu.uswat.fwd82.findmedoc.MainActivity.onCreate(MainActivity.java:22) 
                                                                             at android.app.Activity.performCreate(Activity.java:5179) 
                                                                             at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1146) 
                                                                             at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2336) 
                                                                             at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2424) 
                                                                             at android.app.ActivityThread.handleRelaunchActivity(ActivityThread.java:3956) 
                                                                             at android.app.ActivityThread.access$700(ActivityThread.java:169) 
                                                                             at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1394) 
                                                                             at android.os.Handler.dispatchMessage(Handler.java:107) 
                                                                             at android.os.Looper.loop(Looper.java:194) 
                                                                             at android.app.ActivityThread.main(ActivityThread.java:5433) 
                                                                             at java.lang.reflect.Method.invokeNative(Native Method) 
                                                                             at java.lang.reflect.Method.invoke(Method.java:525) 
                                                                             at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:924) 
                                                                             at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:691) 
                                                                             at dalvik.system.NativeStart.main(Native Method) 
                                                                          Caused by: android.view.InflateException: Binary XML file line #14: Error inflating class ImageView
                                                                             at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:704)
                                                                             at android.view.LayoutInflater.rInflate(LayoutInflater.java:746)
                                                                             at android.view.LayoutInflater.inflate(LayoutInflater.java:489)
                                                                             at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
at android.support.design.internal.NavigationMenuPresenter.inflateHeaderView(NavigationMenuPresenter.java:189)
at android.support.design.widget.NavigationView.inflateHeaderView(NavigationView.java:262)
at android.support.design.widget.NavigationView.<init>(NavigationView.java:173)
at android.support.design.widget.NavigationView.<init>(NavigationView.java:95)
at java.lang.reflect.Constructor.constructNative(Native Method) 
at java.lang.reflect.Constructor.newInstance(Constructor.java:417) 
at android.view.LayoutInflater.createView(LayoutInflater.java:587) 
                                                                             at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:687) 
                                                                             at android.view.LayoutInflater.rInflate(LayoutInflater.java:746) 
                                                                             at android.view.LayoutInflater.inflate(LayoutInflater.java:489) 
                                                                             at android.view.LayoutInflater.inflate(LayoutInflater.java:396) 
                                                                             at android.view.LayoutInflater.inflate(LayoutInflater.java:352) 
                                                                             at android.support.v7.app.AppCompatDelegateImplV7.setContentView(AppCompatDelegateImplV7.java:280) 
                                                                             at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:140) 
                                                                             at edu.uswat.fwd82.findmedoc.MainActivity.onCreate(MainActivity.java:22) 
                                                                             at android.app.Activity.performCreate(Activity.java:5179) 
                                                                             at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1146) 
                                                                             at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2336) 
                                                                             at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2424) 
                                                                             at android.app.ActivityThread.handleRelaunchActivity(ActivityThread.java:3956) 
                                                                             at android.app.ActivityThread.access$700(ActivityThread.java:169) 
                                                                             at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1394) 
                                                                             at android.os.Handler.dispatchMessage(Handler.java:107) 
                                                                             at android.os.Looper.loop(Looper.java:194) 
                                                                             at android.app.ActivityThread.main(ActivityThread.java:5433) 
                                                                             at java.lang.reflect.Method.invokeNative(Native Method) 
                                                                             at java.lang.reflect.Method.invoke(Method.java:525) 
                                                                             at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:924) 
                                                                             at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:691) 
                                                                             at dalvik.system.NativeStart.main(Native Method) 
                                                                          Caused by: java.lang.NullPointerException
                                                                             at android.content.res.ResourcesEx.getThemeDrawable(ResourcesEx.java:459)
                                                                             at android.content.res.ResourcesEx.loadDrawable(ResourcesEx.java:435)
                                                                             at android.content.res.TypedArray.getDrawable(TypedArray.java:609)
                                                                             at android.widget.ImageView.<init>(ImageView.java:120)
                                                                             at android.support.v7.widget.AppCompatImageView.<init>(AppCompatImageView.java:57)
                                                                             at android.support.v7.widget.AppCompatImageView.<init>(AppCompatImageView.java:53)
                                                                             at android.support.v7.app.AppCompatViewInflater.createView(AppCompatViewInflater.java:106)
                                                                             at android.support.v7.app.AppCompatDelegateImplV7.createView(AppCompatDelegateImplV7.java:980)
                                                                             at android.support.v7.app.AppCompatDelegateImplV7.onCreateView(AppCompatDelegateImplV7.java:1039)
                                                                             at android.support.v4.view.LayoutInflaterCompatHC$FactoryWrapperHC.onCreateView(LayoutInflaterCompatHC.java:44)
                                                                         	at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:

As you can see the above Stack Trace include: >android.support.design.widget.NavigationView.inflateHeaderView(NavigationView.java:262) at android.support.design.widget.NavigationView.(NavigationView.java:173) at android.support.design.widget.NavigationView.(NavigationView.java:95)

Solution 7 - Android

I solved it downgrading in gradle from

compile 'com.android.support:design:23.1.0'

to

compile 'com.android.support:design:23.0.1'

It seems like I always get problems when I update any component of Android Studio. Getting tired of it.

Solution 8 - Android

None of the above fixes worked for me.

What worked for me was changing

<item name="android:textColorSecondary">#FFFFFF</item>

to

<item name="android:textColorSecondary">@color/colorWhite</item>

You obviously need to add colorWhite to your colors.xml

Solution 9 - Android

Following below steps will surely remove this error.

  • Find the widget causing the error.
  • Go the layout file where that widget is declared.
  • Check for all the resources (drawables etc.) used in that file.
  • Then make sure that resource is there in all versions of drawables (drawable-v21,drawable etc.)

Cheers!!

Solution 10 - Android

As Parag Naik correctly mentions (and Lạng Hoàng expands on), the problem arises when setting textColorPrimary to something other than a color state list. So you could set textColorPrimary as a state list. There is an issue in the android bug tracker about colorPrimary being a state list with only one color: https://code.google.com/p/android/issues/detail?id=172353

So for your theme in styles.xml:

<style name="Base.Theme.Hopster" parent="Theme.AppCompat.Light.NoActionBar">
    <item name="colorPrimary">@color/primary</item>
    <item name="colorPrimaryDark">@color/primary_dark</item>
    <item name="colorAccent">@color/accent</item>

    <item name="android:textColorPrimary">@color/primary_color_statelist</item>
</style>

And the actual primary_color_statelist.xml file:

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
    <!-- This is used when the Navigation Item is checked -->
    <item android:color="@color/primary_text_selected" android:state_checked="true" />
    <!-- This is the default text color -->
    <item android:color="@color/primary_text" />
</selector>

Solution 11 - Android

In my case, I had the same error when I run the app in kitkat API 19 version device. I figured out the problem; I had some drawable resources which was in the drawable-v21 directory (Which is used for versions from API 21 Lollipop). I just put the same resources in the "Drawable" folder to work with the version below API 21. It works. You can put it on the corresponding directory

Solution 12 - Android

For me, I encountered this error many times,

Error inflating class android.support.design.widget.NavigationView #28 and #29

The solution that works for me is that you must match your support design library and your support appcompat library.

compile 'com.android.support:appcompat-v7:23.1.1'

compile 'com.android.support:design:23.1.1'

For me they must match. :) It works for me!

Solution 13 - Android

Just for who still get to this issue. I got to the same problem but all the solutions here is not work for me.

Just take alook on NavigationView class with cue from logcat, i found the issue come form this line of code:

itemTextColor = this.createDefaultColorStateList(16842806);

So, it seem related to itemTextColor as Aenur56 mentioned. So i tried with Aenur56's solution but it doesn't work.

Take a look on the line of code above, i notice that there is ColorStateList. So i create one then set for itemTextColor then it work.

<selector xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:color="#00FF00" android:state_checked="true" />
    <item android:color="#000000" />
</selector>

Hope it help!

Solution 14 - Android

None of the solutions above helped me. I found this on some other webpage and it worked for me - "In project.properties of design library set target to 21 or highest available, then clean design lib, appcomapt and your project and enjoy"

Hope it will help!

Solution 15 - Android

Make sure your drawables for the menu are in the correct folder, mine where put in drawablev21 hence this caused a nullpointer to the resource.

Fixed it buy moving my icons to drawables folder

Solution 16 - Android

Generic way of solving issues like Error inflating class X:

  1. check cause stack trace and there should be Resources$NotFoundException like this:

> Caused by: android.content.res.Resources$NotFoundException: Resource ID #0x7f0b0066 > at android.content.res.ResourcesImpl.getValue(ResourcesImpl.java:190) > at android.content.res.Resources.loadXmlResourceParser(Resources.java:2094) > at android.content.res.Resources.getLayout(Resources.java:1111) > at android.view.LayoutInflater.inflate(LayoutInflater.java:424)

  1. Resource ID is actually exact integer from generated R.java file.
  2. Find 0x7f0b0066 which will point to the xml file which could not be inflated(found).
  3. In most cases that's because directory layout doesn't have this resource, but some layout-XXX has.
  4. And solution is to put resource into all required directories. Or just at least into layout.

Solution 17 - Android

In my case i had

<android.support.design.widget.NavigationView...

and in app config:

implementation 'com.google.android.material:material:1.1.0'
implementation 'androidx.appcompat:appcompat:1.1.0'

So I changed the XML to:

com.google.android.material.navigation.NavigationView...

Solution 18 - Android

I had the same problem after upgrading the support library and none of the answers worked for me. Finally I solved downloading latest version of build tools and upgrading in build.gradle to buildToolsVersion "23.0.1"

Solution 19 - Android

One thing to double-check is that you have applied your theme correctly in your AndroidManifest.xml file. In my case, I had omitted the android:theme attribute. E.g:

<application ... android:theme="@style/Your.Theme.Here" ... >

Solution 20 - Android

BETTER I UPGRADED com.android.support:appcompat-v7:23.1.0

as @Ton said downgrade compile 'com.android.support:design:23.1.0'

BUT Why not to upgrade com.android.support:appcompat-v7:23.1.1

Final upgraded worked for me enjoy

compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.android.support:design:23.1.1'

So why to use older library. I think is now better to use both design and compact upgraded.

Solution 21 - Android

This error can be caused due to reasons as mentioned below.

  1. This problem will likely occur when the version of your appcompat library and design support library doesn't match. Example of matching condition

      compile 'com.android.support:appcompat-v7:24.2.0' // appcompat library
    
      compile 'com.android.support:design:24.2.0' //design support library
    
  2. If your theme file in styles have only these two,

      <item name="colorPrimary">#4A0958</item>
      <item name="colorPrimaryDark">#4A0958</item>
    

then add ColorAccent too. It should look somewhat like this.

 <style name="AppTheme.Base" parent="Theme.AppCompat.Light.NoActionBar">

  <item name="colorPrimary">#4A0958</item>
  <item name="colorPrimaryDark">#4A0958</item>
  <item name="colorAccent">#4A0958</item>

 </style>

Solution 22 - Android

I was also having this same issue, after looking nearly 3 hours I find out that the problem was in my drawable_menu.xml file, it was wrongly written :D

Solution 23 - Android

It's weird but clean project and rebuild project worked for me.

Solution 24 - Android

I found solution... if you used app:srcCompat change to android:src this solution worked for me :)

Solution 25 - Android

I was facing this error in Xamarin. This was due to some files that were present in drawable-v21 folder. So I copied those files (probably icon files) to the drawable folder and the error was gone.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionpptangView Question on Stackoverflow
Solution 1 - AndroidBalman RawatView Answer on Stackoverflow
Solution 2 - AndroidParag NaikView Answer on Stackoverflow
Solution 3 - AndroidSajalView Answer on Stackoverflow
Solution 4 - AndroidMark PazonView Answer on Stackoverflow
Solution 5 - AndroidPidikanView Answer on Stackoverflow
Solution 6 - AndroidfWd82View Answer on Stackoverflow
Solution 7 - AndroidTonView Answer on Stackoverflow
Solution 8 - AndroidRafal RoszakView Answer on Stackoverflow
Solution 9 - AndroidPrashant PaliwalView Answer on Stackoverflow
Solution 10 - AndroidChrisView Answer on Stackoverflow
Solution 11 - AndroidJackView Answer on Stackoverflow
Solution 12 - AndroidRoCk RoCkView Answer on Stackoverflow
Solution 13 - AndroidLạng HoàngView Answer on Stackoverflow
Solution 14 - AndroidMichał StawskiView Answer on Stackoverflow
Solution 15 - AndroidIsmael ozilView Answer on Stackoverflow
Solution 16 - AndroidelevenView Answer on Stackoverflow
Solution 17 - AndroidMihaiView Answer on Stackoverflow
Solution 18 - AndroidErickView Answer on Stackoverflow
Solution 19 - AndroidDavid ConliskView Answer on Stackoverflow
Solution 20 - AndroidkaranView Answer on Stackoverflow
Solution 21 - AndroidVishal PuriView Answer on Stackoverflow
Solution 22 - AndroidAntarixView Answer on Stackoverflow
Solution 23 - AndroidshabyView Answer on Stackoverflow
Solution 24 - AndroidKhun Htetz NaingView Answer on Stackoverflow
Solution 25 - AndroidJunaid PathanView Answer on Stackoverflow