Error inflating class android.support.design.widget.NavigationView - android
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
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
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
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 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.
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.
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 ... />
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.
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)
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.
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
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!!
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>
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
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!
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!
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!
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
Generic way of solving issues like Error inflating class X:
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)
Resource ID is actually exact integer from generated R.java file.
Find 0x7f0b0066 which will point to the xml file which could not be inflated(found).
In most cases that's because directory layout doesn't have this resource, but some layout-XXX has.
And solution is to put resource into all required directories. Or just at least into layout.
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...
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"
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" ... >
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.
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
This error can be caused due to reasons as mentioned below.
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
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>
It's weird but clean project and rebuild project worked for me.
I found solution...
if you used app:srcCompat change to android:src
this solution worked for me :)
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.
Related
Navigation View Inflation error in android api 23 [duplicate]
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 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
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
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 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.
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.
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 ... />
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.
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)
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.
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
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!!
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>
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
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!
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!
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!
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
Generic way of solving issues like Error inflating class X: 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) Resource ID is actually exact integer from generated R.java file. Find 0x7f0b0066 which will point to the xml file which could not be inflated(found). In most cases that's because directory layout doesn't have this resource, but some layout-XXX has. And solution is to put resource into all required directories. Or just at least into layout.
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...
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"
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" ... >
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.
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
This error can be caused due to reasons as mentioned below. 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 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>
It's weird but clean project and rebuild project worked for me.
I found solution... if you used app:srcCompat change to android:src this solution worked for me :)
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.
Exception from LayerDrawable
I've an android app that using android support library version 23.2.1 and everything is working fine. However, I've updated the android support library version to 25.2.0 yesterday and realize some of the user are getting this exception (through Fabric crashlytics) but I couldn't reproduce it. Here is the crash log: Fatal Exception: java.lang.NullPointerException: Attempt to invoke virtual method 'android.graphics.drawable.Drawable android.graphics.drawable.Drawable$ConstantState.newDrawable(android.content.res.Resources)' on a null object reference at android.graphics.drawable.LayerDrawable$ChildDrawable.<init>(LayerDrawable.java:959) at android.graphics.drawable.LayerDrawable$LayerState.<init>(LayerDrawable.java:1007) at android.graphics.drawable.LayerDrawable.createConstantState(LayerDrawable.java:133) at android.graphics.drawable.LayerDrawable.<init>(LayerDrawable.java:126) at android.graphics.drawable.LayerDrawable$LayerState.newDrawable(LayerDrawable.java:1048) at android.content.res.Resources.getCachedDrawableLocked(Resources.java:2777) at android.content.res.Resources.getCachedDrawable(Resources.java:2745) at android.content.res.Resources.loadDrawable(Resources.java:2586) at android.content.res.Resources.getDrawable(Resources.java:900) at android.content.Context.getDrawable(Context.java:408) at android.support.v4.content.ContextCompatApi21.getDrawable(ContextCompatApi21.java:30) at android.support.v4.content.ContextCompat.getDrawable(ContextCompat.java:372) at android.support.v7.widget.AppCompatDrawableManager.getDrawable(AppCompatDrawableManager.java:202) at android.support.v7.widget.AppCompatDrawableManager.getDrawable(AppCompatDrawableManager.java:190) at android.support.v7.content.res.AppCompatResources.getDrawable(AppCompatResources.java:100) at android.support.v7.view.menu.MenuItemImpl.getIcon(MenuItemImpl.java:425) at android.support.v7.view.menu.ActionMenuItemView.initialize(ActionMenuItemView.java:129) at android.support.v7.widget.ActionMenuPresenter.bindItemView(ActionMenuPresenter.java:211) at android.support.v7.view.menu.BaseMenuPresenter.getItemView(BaseMenuPresenter.java:186) at android.support.v7.widget.ActionMenuPresenter.getItemView(ActionMenuPresenter.java:197) at android.support.v7.widget.ActionMenuPresenter.flagActionItems(ActionMenuPresenter.java:479) at android.support.v7.view.menu.MenuBuilder.flagActionItems(MenuBuilder.java:1160) at android.support.v7.view.menu.BaseMenuPresenter.updateMenuView(BaseMenuPresenter.java:95) at android.support.v7.widget.ActionMenuPresenter.updateMenuView(ActionMenuPresenter.java:234) at android.support.v7.view.menu.MenuBuilder.dispatchPresenterUpdate(MenuBuilder.java:292) at android.support.v7.view.menu.MenuBuilder.onItemsChanged(MenuBuilder.java:1047) at android.support.v7.view.menu.MenuBuilder.startDispatchingItemsChanged(MenuBuilder.java:1074) at android.support.v7.app.ToolbarActionBar.populateOptionsMenu(ToolbarActionBar.java:460) at android.support.v7.app.ToolbarActionBar$1.run(ToolbarActionBar.java:61) at android.os.Handler.handleCallback(Handler.java:815) at android.os.Handler.dispatchMessage(Handler.java:104) at android.os.Looper.loop(Looper.java:194) at android.app.ActivityThread.main(ActivityThread.java:5637) at java.lang.reflect.Method.invoke(Method.java) at java.lang.reflect.Method.invoke(Method.java:372) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:959) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:754) It seems to do with menu view. The layout for menu option is: <?xml version="1.0" encoding="utf-8"?> <menu xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" tools:context=".tablet.ui.navimenu.ContainerActivity"> <item android:id="#+id/memo_fragment" android:icon="#drawable/ic_class_white_24dp" android:orderInCategory="100" android:title="#string/memo_fragment" app:showAsAction="always" /> <item android:id="#+id/notification_fragment" android:icon="#drawable/layerlist_menu_notification" android:orderInCategory="200" android:title="#string/notification_fragment" app:showAsAction="always" /> </menu> layerlist_menu_notification layout is an icon with a badge: <?xml version="1.0" encoding="utf-8"?> <layer-list xmlns:android="http://schemas.android.com/apk/res/android"> <item android:id="#+id/ic_notification" android:drawable="#drawable/ic_notifications_white_24dp" android:gravity="center" /> <!-- set a place holder Drawable so android:drawable isn't null --> <item android:id="#+id/ic_badge" android:drawable="#drawable/ic_notifications_white_24dp" /> </layer-list> Any idea where goes wrong?
Try Change the following in build.gradle compileSdkVersion 25 buildToolsVersion "25.0.2" compile 'com.android.support:appcompat-v7:25.1.0' compile 'com.android.support:design:25.1.0' compile 'com.android.support:support-v4:25.1.0'
Android action bar crashes with theme
I use Google's support libraries of version 23.1.0. compile 'com.android.support:appcompat-v7:23.1.0' compile 'com.android.support:recyclerview-v7:23.1.0' compile 'com.android.support:cardview-v7:23.1.0' compile 'com.android.support:preference-v7:23.1.0' compile 'com.android.support:design:23.1.0' I am reusing a theme file that worked with versions of the support libraries prior to the introduction of material design. <style name="AppTheme.StatusBarOverlay.Main" parent="#style/AppTheme.Main"> <item name="android:windowContentOverlay">#null</item> </style> <style name="AppTheme.Main" parent="#style/AppBaseTheme.Main"> <item name="windowActionBar">false</item> </style> <style name="AppBaseTheme.Main" parent="#style/Theme.AppCompat.Main"> <item name="colorPrimary">#color/main_color</item> <item name="colorPrimaryDark">#color/main_color_dk</item> </style> <style name="Theme.AppCompat.Main" parent="#style/Base.Theme.AppCompat.Main" /> <style name="Base.Theme.AppCompat.Main" parent="#style/Base.V7.Theme.AppCompat" /> <style name="Theme.CustomDialog" parent="#android:style/Theme.Dialog"> <item name="android:windowBackground">#drawable/trans_draw</item> <item name="android:windowNoTitle">true</item> </style> I made my MainActivity use the style by setting the theme in the manifest <activity android:name=".activities.MainActivity" android:label="#string/title_activity_main" android:theme="#style/AppTheme.StatusBarOverlay.Main" > </activity> When the action bar was retrieved ActionBar actionBar = getSupportActionBar(); the following exception was raised. Caused by: java.lang.IllegalArgumentException: AppCompat does not support the current theme features: { windowActionBar: false, windowActionBarOverlay: false, android:windowIsFloating: false, windowActionModeOverlay: false, windowNoTitle: false } at android.support.v7.app.AppCompatDelegateImplV7.createSubDecor(AppCompatDelegateImplV7.java:423) at android.support.v7.app.AppCompatDelegateImplV7.ensureSubDecor(AppCompatDelegateImplV7.java:280) at android.support.v7.app.AppCompatDelegateImplV7.initWindowDecorActionBar(AppCompatDelegateImplV7.java:173) at android.support.v7.app.AppCompatDelegateImplBase.getSupportActionBar(AppCompatDelegateImplBase.java:89) at android.support.v7.app.AppCompatActivity.getSupportActionBar(AppCompatActivity.java:79) at com.dynamicwebapac.commerce.mobile.custom.CustomActivity.setupActionBar(CustomActivity.java:39) at com.dynamicwebapac.commerce.mobile.custom.CustomActivity.onCreate(CustomActivity.java:25) at com.dynamicwebapac.commerce.mobile.activities.MainActivity.onCreate(MainActivity.java:181) at android.app.Activity.performCreate(Activity.java:5933) at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1105) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2251) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2360) at android.app.ActivityThread.access$800(ActivityThread.java:144) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1278) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:135) at android.app.ActivityThread.main(ActivityThread.java:5221) at java.lang.reflect.Method.invoke(Native Method) at java.lang.reflect.Method.invoke(Method.java:372) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694) What happened to the Android support library after material design was introduced? How can I solve my current problem?
Using the new material support library, we set up themes like this styles.xml <?xml version="1.0" encoding="utf-8"?> <resources> <style name="AppTheme" parent="Theme.AppCompat.NoActionBar"> <item name="colorPrimary">#color/colorPrimary</item> <item name="colorPrimaryDark">#color/colorPrimaryDark</item> <item name="colorAccent">#color/colorAccent</item> </style> Also in the manifest android:theme="#style/AppTheme" And then we use the Toolbar as the action bar .Do this in your parent layout <android.support.v7.widget.Toolbar android:id="#+id/toolbar" android:layout_width="match_parent" android:layout_height="?attr/actionBarSize" android:background="?attr/colorPrimary" /> And we set it up in our Java source using Toolbar toolbar=(Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar);
Don't worry it happens with most of us. I'd like to start with reason of this problem. The Material Design is in the favour of using Toolbar which is more flexible,...etc hence the themes or styles provided by AppCompat library are without an ActionBar or you can say a support ActionBar is provided and hence e need to disable the system default ActionBar. Now follow any of the 2 steps below as suggested by Colns Abt: Add any style which has NoActionBar at the ending like Theme.AppCompat.NoActionBar OR Add the following lines in your custom style <item name="windowActionBar">false</item> <item name="android:windowNoTitle">true</item> Further follow steps given by Colns Abt.
"You need to use a theme.appcompat theme" with Theme.AppCompat as theme, Sdk v23
Config: Android Studio 1.4 Preview 2 compileSdkVersion 23 buildToolsVersion '23' minSdkVersion 15 targetSdkVersion 23 Up-to-date support libraries (v23) Error: [updated] java.lang.RuntimeException: Unable to start activity ComponentInfo{com.myapp.android.debug/com.myapp.mobile.activities.HomeActivity}: java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity. at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2416) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476) at android.app.ActivityThread.-wrap11(ActivityThread.java) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:148) at android.app.ActivityThread.main(ActivityThread.java:5417) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616) Caused by: java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity. at android.support.v7.app.k.onCreate(AppCompatDelegateImplBase.java:124) at android.support.v7.app.AppCompatDelegateImplV7.onCreate(AppCompatDelegateImplV7.java:146) at android.support.v7.app.AppCompatActivity.onCreate(AppCompatActivity.java:59) at com.myapp.mobile.activities.BaseActivity.onCreate(BaseActivity.java:47) at com.myapp.mobile.activities.HomeActivity.onCreate(HomeActivity.java:57) at android.app.Activity.performCreate(Activity.java:6237) at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1107) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2369) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476) at android.app.ActivityThread.-wrap11(ActivityThread.java) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:148) at android.app.ActivityThread.main(ActivityThread.java:5417) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616) My application was working well before switching to v23 (previous config was v22 and support libraries v22.2.1. After upgrading, compilation is done correctly but this error appears just at launch. I have seen many posts on SO where the problem comes from a bad styling, with a Holo parent. Tricky problem found their origin in Manifest file, where an activity theme overrides app theme. It's my case, so I changed for test purpose my manifest to: <application android:name=".MyApplication" android:allowBackup="true" android:hardwareAccelerated="true" android:icon="#mipmap/ic_launcher" android:label="#string/app_name" android:largeHeap="true" android:theme="#style/Theme.BaseMyApp"> <!-- Launch activity. MyApp.Theme has Theme.BaseMyApp for parent, but has 2 more attributes for v21 --> <activity android:name=".activities.HomeActivity" android:launchMode="singleTop" android:theme="#style/MyApp.Theme"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.DEFAULT" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> ... but, how strange, the error still occurs! I also have checked views of activity layout, but nothing seems to be a problem, only a Toolbar which theme extends AppCompat: toolbar_layout.xml <merge xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto"> <android.support.v7.widget.Toolbar android:id="#+id/toolbar" android:layout_width="match_parent" android:layout_height="?attr/actionBarSize" android:background="?attr/colorPrimary" android:fitsSystemWindows="true" android:theme="#style/AppTheme.Toolbar" app:subtitleTextAppearance="#style/AppTheme.Toolbar.SubTitle" app:titleTextAppearance="#style/AppTheme.Toolbar.Title"> <ProgressBar android:id="#+id/progress_spinner" style="#style/Widget.MyApp.ActionBar.Progress" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="right" android:indeterminate="true" android:visibility="gone" /> </android.support.v7.widget.Toolbar> where <style name="AppTheme.Toolbar" parent="ThemeOverlay.AppCompat.ActionBar"> <!-- Customize color of navigation drawer icon and back arrow --> <item name="colorControlNormal">#android:color/white</item> </style> <style name="AppTheme.Toolbar.Title" parent="TextAppearance.Widget.AppCompat.Toolbar.Title"> <!-- Set proper title size --> <item name="android:textSize">#dimen/abc_text_size_title_material_toolbar</item> <!-- Set title color --> <item name="android:textColor">#android:color/white</item> </style> <style name="AppTheme.Toolbar.SubTitle" parent="TextAppearance.Widget.AppCompat.Toolbar.Subtitle"> <!-- Set proper title size --> <item name="android:textSize">#dimen/abc_text_size_subtitle_material_toolbar</item> <!-- Set title color --> <item name="android:textColor">#android:color/white</item> </style> <style name="Widget.MyApp.ActionBar.Progress" parent="Widget.AppCompat.ProgressBar"> <item name="android:minHeight">25dp</item> <item name="android:maxHeight">25dp</item> </style> Do you have an idea where I have messed it up? Thanks
Problem partially solved. The guilty line is: at android.support.v7.app.k.onCreate(AppCompatDelegateImplBase.java:124) I use these separate ProGuard files to configure ProGuard. Maybe I didn't point to the correct /app/proguard directory. Thus, ProGuard ignored myapp-rules.pro where I say to keep those android.support.v7.**classes. After fixing this, I had the error: :app:proguardDebug Warning: com.paypal.android.sdk.aT: can't find referenced field 'org.apache.http.HttpEntity wrappedEntity' in program class com.paypal.android.sdk.aT Warning: uk.co.senab.photoview.PhotoViewAttacher: can't find referenced method 'float sqrt(float)' in library class android.util.FloatMath Warning: uk.co.senab.photoview.gestures.CupcakeGestureDetector: can't find referenced method 'float sqrt(float)' in library class android.util.FloatMath Warning: there were 1 unresolved references to program class members. Your input classes appear to be inconsistent. You may need to recompile the code. (http://proguard.sourceforge.net/manual/troubleshooting.html#unresolvedprogramclassmember) Warning: there were 2 unresolved references to library class members. You probably need to update the library versions. (http://proguard.sourceforge.net/manual/troubleshooting.html#unresolvedlibraryclassmember) Exception while processing task java.io.IOException: Please correct the above warnings first. at proguard.Initializer.execute(Initializer.java:473) at proguard.ProGuard.initialize(ProGuard.java:233) at proguard.ProGuard.execute(ProGuard.java:98) at proguard.gradle.ProGuardTask.proguard(ProGuardTask.java:1074) at com.android.build.gradle.tasks.AndroidProGuardTask.doMinification(AndroidProGuardTask.java:139) at com.android.build.gradle.tasks.AndroidProGuardTask$1.run(AndroidProGuardTask.java:115) at com.android.builder.tasks.Job.runTask(Job.java:48) at com.android.build.gradle.tasks.SimpleWorkQueue$EmptyThreadContext.runTask(SimpleWorkQueue.java:41) at com.android.builder.tasks.WorkQueue.run(WorkQueue.java:227) at java.lang.Thread.run(Thread.java:745) :app:dexDebug :app:crashlyticsStoreDeobsDebug :app:crashlyticsUploadDeobsDebug :app:validateDebugSigning :app:packageDebug FAILED FAILURE: Build failed with an exception. * What went wrong: Execution failed for task ':app:packageDebug'. > Unable to compute hash of /home/guillaume/workspace/MyApp/app/build/intermediates/classes-proguard/debug/classes.jar So I 'fixed' the warnings by adding rules -dontwarn com.paypal.android.sdk.** -dontwarn uk.co.senab.photoview.** Yet the problem seems deeper, as PhotoView and Braintree/Card.io (also PayPal SDK) use methods removed with API 23. The ball is not in my count, is it?
Thanks for your update. Maybe your toolbar parent is the problem. It has another inheritance than Theme.AppCompat. <style name="AppTheme.Toolbar" parent="ThemeOverlay.AppCompat.ActionBar"> <!-- Customize color of navigation drawer icon and back arrow --> <item name="colorControlNormal">#android:color/white</item> </style> Try using this for your toolbar: "Widget.AppCompat.Toolbar" as parent
InflateException with FloatingActionButton from Official Design Library
I am getting a bug using the official FloatingActionButton from Google's support design library. Here is my LogCat. android.view.InflateException: Binary XML file line #34: Error inflating class android.support.design.widget.FloatingActionButton at android.view.LayoutInflater.createView(LayoutInflater.java:633) at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:743) at android.view.LayoutInflater.rInflate(LayoutInflater.java:806) at android.view.LayoutInflater.rInflate(LayoutInflater.java:809) at android.view.LayoutInflater.inflate(LayoutInflater.java:504) at de.robv.android.xposed.XposedBridge.invokeOriginalMethodNative(Native Method) at de.robv.android.xposed.XposedBridge.handleHookedMethod(XposedBridge.java:655) at android.view.LayoutInflater.inflate(Unknown Source) at android.view.LayoutInflater.inflate(LayoutInflater.java:414) at ---.---.com.---.SubCategoryFragment.onCreateView(SubCategoryFragment.java:47) at android.support.v4.app.Fragment.performCreateView(Fragment.java:1789) at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:955) at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1138) at android.support.v4.app.BackStackRecord.run(BackStackRecord.java:740) at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1501) at android.support.v4.app.FragmentManagerImpl$1.run(FragmentManager.java:458) at android.os.Handler.handleCallback(Handler.java:739) at android.os.Handler.dispatchMessage(Handler.java:95) at android.os.Looper.loop(Looper.java:135) at android.app.ActivityThread.main(ActivityThread.java:5221) at java.lang.reflect.Method.invoke(Native Method) at java.lang.reflect.Method.invoke(Method.java:372) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694) at de.robv.android.xposed.XposedBridge.main(XposedBridge.java:117) Caused by: java.lang.reflect.InvocationTargetException at java.lang.reflect.Constructor.newInstance(Native Method) at java.lang.reflect.Constructor.newInstance(Constructor.java:288) at android.view.LayoutInflater.createView(LayoutInflater.java:607) ... 24 more Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'android.graphics.drawable.Drawable android.graphics.drawable.Drawable$ConstantState.newDrawable()' on a null object reference at android.graphics.drawable.LayerDrawable$ChildDrawable.<init>(LayerDrawable.java:968) at android.graphics.drawable.LayerDrawable$LayerState.<init>(LayerDrawable.java:1014) at android.graphics.drawable.RippleDrawable$RippleState.<init>(RippleDrawable.java:910) at android.graphics.drawable.RippleDrawable.createConstantState(RippleDrawable.java:901) at android.graphics.drawable.RippleDrawable.createConstantState(RippleDrawable.java:90) at android.graphics.drawable.LayerDrawable.mutate(LayerDrawable.java:932) at android.graphics.drawable.RippleDrawable.mutate(RippleDrawable.java:891) at android.view.View.applyBackgroundTint(View.java:16324) at android.view.View.setBackgroundDrawable(View.java:16193) at android.support.design.widget.FloatingActionButton.access$201(FloatingActionButton.java:56) at android.support.design.widget.FloatingActionButton$1.setBackgroundDrawable(FloatingActionButton.java:118) at android.support.design.widget.FloatingActionButtonLollipop.setBackgroundDrawable(FloatingActionButtonLollipop.java:75) at android.support.design.widget.FloatingActionButton.<init>(FloatingActionButton.java:131) at android.support.design.widget.FloatingActionButton.<init>(FloatingActionButton.java:79) ... 27 more The only line that points to my app is where it inflates the xml file, and the line in that file which is my FloatingActionButton. <android.support.design.widget.FloatingActionButton android:id="#+id/myFABSubCat" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentBottom="true" android:layout_alignParentEnd="true" android:layout_alignParentRight="true" android:layout_margin="16dp" android:backgroundTint="#color/accent" android:src="#drawable/add_icon" app:borderWidth="0dp" app:elevation="4sp" /> Extra info: Here is my app theme: <resources> <!-- Base application theme. --> <style name="MBTIAppTheme" parent="Theme.AppCompat.Light.NoActionBar"> <item name="colorPrimary">#color/primary</item> <item name="colorPrimaryDark">#color/primaryDark</item> <item name="colorAccent">#color/accent</item> <item name="android:windowContentOverlay">#null</item> </style> <style name="ThemeNoActionBar" parent="MBTIAppTheme"> <item name="windowActionBar">false</item> </style> </resources> Yes, I am using an AppCompatActivity. I noticed I am using an older version of appcompat: com.android.support:appcompat-v7:22.1.1 This seems to be up to date: compile 'com.android.support:design:22.2.0' Also, minSdkVersion 16 targetSdkVersion 22 Now, I do set the Visibility to GONE in some case for my FAB, but this is after it inflates so that can't be the issue. Now, this works with my 5.1 device, but the users who have issues have 5.0. Is this a known bug or maybe I am doing something wrong?
com.android.support:appcompat-v7:21+ added support for tinting widgets on devices running pre android 5.1 (API Level 21). To make use of it make sure you extend or set the AppCompat Theme and use app:backgroundTint instead of android:backgroundTint. Example: <android.support.design.widget.FloatingActionButton xmlns:app="http://schemas.android.com/apk/res-auto" android:id="#+id/fab" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_margin="16dp" android:src="#drawable/icon" app:backgroundTint="#color/accent" app:borderWidth="0dp" />
Just replace <android.support.design.widget.FloatingActionButton ... ... android:backgroundTint /> to <android.support.design.widget.FloatingActionButton ... ... app:backgroundTint />
If you're using a VectorDrawableCompat (Vector asset) you should use: app:srcCompat="#drawable/x" instead of: android:src="#drawable/x"
I had the same issue and tried different solution. But the one that worked for me was to ensure that appcompat and design support library versions are the same. for example: compile 'com.android.support:appcompat-v7:23.2.0' compile 'com.android.support:design:23.2.0'
Just change android to app: android:backgroundTint="#color/accent" To: app:backgroundTint="#color/accent"
Another way to get this message is if you accidentally specified different versions of the appcompat library in different modules. This is likely to happen when you create a new module, since Android Studio defaults to the most current version. For a tidy way of managing this in multi-module projects, see: In Gradle, how do I declare common dependencies in a single place?
in my case, it was because of the false configuration of activity theme. problem was solved after i changed app theme to Theme.AppCompat.xxx.