Resources$NotFoundException: File res/drawable/abc_ic_ab_back_material.xml - android

After solving a JDK zero value error, now I'm facing this one. I did a little research, but it seems I can't get to the point. Here is the log error:
FATAL EXCEPTION: main
E/AndroidRuntime: java.lang.RuntimeException: Unable to start activity ComponentInfo{.MainActivity}: android.content.res.Resources$NotFoundException: File res/drawable/abc_ic_ab_back_material.xml from drawable resource ID #0x7f020013
E/AndroidRuntime: at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2204)
E/AndroidRuntime: at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2254)
E/AndroidRuntime: at android.app.ActivityThread.access$600(ActivityThread.java:141)
E/AndroidRuntime: at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)
E/AndroidRuntime: at android.os.Handler.dispatchMessage(Handler.java:99)
E/AndroidRuntime: at android.os.Looper.loop(Looper.java:137)
E/AndroidRuntime: at android.app.ActivityThread.main(ActivityThread.java:5069)
E/AndroidRuntime: at java.lang.reflect.Method.invokeNative(Native Method)
E/AndroidRuntime: at java.lang.reflect.Method.invoke(Method.java:511)
E/AndroidRuntime: at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
E/AndroidRuntime: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
E/AndroidRuntime: at dalvik.system.NativeStart.main(Native Method)
E/AndroidRuntime: Caused by: android.content.res.Resources$NotFoundException: File res/drawable/abc_ic_ab_back_material.xml from drawable resource ID #0x7f020013
E/AndroidRuntime: at android.content.res.Resources.loadDrawable(Resources.java:1953)
E/AndroidRuntime: at android.content.res.Resources.getDrawable(Resources.java:660)
E/AndroidRuntime: at android.support.v4.content.ContextCompat.getDrawable(ContextCompat.java:354)
E/AndroidRuntime: at android.support.v7.widget.AppCompatDrawableManager.getDrawable(AppCompatDrawableManager.java:193)
E/AndroidRuntime: at android.support.v7.widget.AppCompatDrawableManager.getDrawable(AppCompatDrawableManager.java:181)
E/AndroidRuntime: at android.support.v7.widget.AppCompatDrawableManager.checkVectorDrawableSetup(AppCompatDrawableManager.java:689)
E/AndroidRuntime: at android.support.v7.widget.AppCompatDrawableManager.getDrawable(AppCompatDrawableManager.java:186)
E/AndroidRuntime: at android.support.v7.widget.TintTypedArray.getDrawableIfKnown(TintTypedArray.java:77)
E/AndroidRuntime: at android.support.v7.app.AppCompatDelegateImplBase.<init>(AppCompatDelegateImplBase.java:83)
E/AndroidRuntime: at android.support.v7.app.AppCompatDelegateImplV7.<init>(AppCompatDelegateImplV7.java:146)
E/AndroidRuntime: at android.support.v7.app.AppCompatDelegateImplV11.<init>(AppCompatDelegateImplV11.java:28)
E/AndroidRuntime: at android.support.v7.app.AppCompatDelegateImplV14.<init>(AppCompatDelegateImplV14.java:41)
E/AndroidRuntime: at android.support.v7.app.AppCompatDelegate.create(AppCompatDelegate.java:193)
E/AndroidRuntime: at android.support.v7.app.AppCompatDelegate.create(AppCompatDelegate.java:173)
E/AndroidRuntime: at android.support.v7.app.AppCompatActivity.getDelegate(AppCompatActivity.java:511)
E/AndroidRuntime: at android.support.v7.app.AppCompatActivity.onCreate(AppCompatActivity.java:71)
E/AndroidRuntime: at .MainActivity.onCreate(MainActivity.java:29)
E/AndroidRuntime: at android.app.Activity.performCreate(Activity.java:5104)
E/AndroidRuntime: at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1092)
E/AndroidRuntime: at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2148)
E/AndroidRuntime: at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2254) 
E/AndroidRuntime: at android.app.ActivityThread.access$600(ActivityThread.java:141) 
E/AndroidRuntime: at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234) 
E/AndroidRuntime: at android.os.Handler.dispatchMessage(Handler.java:99) 
E/AndroidRuntime: at android.os.Looper.loop(Looper.java:137) 
E/AndroidRuntime: at android.app.ActivityThread.main(ActivityThread.java:5069) 
E/AndroidRuntime: at java.lang.reflect.Method.invokeNative(Native Method) 
E/AndroidRuntime: at java.lang.reflect.Method.invoke(Method.java:511) 
E/AndroidRuntime: at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793) 
E/AndroidRuntime: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560) 
E/AndroidRuntime: at dalvik.system.NativeStart.main(Native Method) 
E/AndroidRuntime: Caused by: org.xmlpull.v1.XmlPullParserException: Binary XML file line #17: invalid drawable tag vector
E/AndroidRuntime: at android.graphics.drawable.Drawable.createFromXmlInner(Drawable.java:881)
E/AndroidRuntime: at android.graphics.drawable.Drawable.createFromXml(Drawable.java:822)
E/AndroidRuntime: at android.content.res.Resources.loadDrawable(Resources.java:1950)
E/AndroidRuntime: at android.content.res.Resources.getDrawable(Resources.java:660) 
E/AndroidRuntime: at android.support.v4.content.ContextCompat.getDrawable(ContextCompat.java:354) 
E/AndroidRuntime: at android.support.v7.widget.AppCompatDrawableManager.getDrawable(AppCompatDrawableManager.java:193) 
E/AndroidRuntime: at android.support.v7.widget.AppCompatDrawableManager.getDrawable(AppCompatDrawableManager.java:181) 
E/AndroidRuntime: at android.support.v7.widget.AppCompatDrawableManager.checkVectorDrawableSetup(AppCompatDrawableManager.java:689) 
E/AndroidRuntime: at android.support.v7.widget.AppCompatDrawableManager.getDrawable(AppCompatDrawableManager.java:186) 
E/AndroidRuntime: at android.support.v7.widget.TintTypedArray.getDrawableIfKnown(TintTypedArray.java:77) 
E/AndroidRuntime: at android.support.v7.app.AppCompatDelegateImplBase.<init>(AppCompatDelegateImplBase.java:83) 
E/AndroidRuntime: at android.support.v7.app.AppCompatDelegateImplV7.<init>(AppCompatDelegateImplV7.java:146) 
E/AndroidRuntime: at android.support.v7.app.AppCompatDelegateImplV11.<init>(AppCompatDelegateImplV11.java:28) 
E/AndroidRuntime: at android.support.v7.app.AppCompatDelegateImplV14.<init>(AppCompatDelegateImplV14.java:41) 
E/AndroidRuntime: at android.support.v7.app.AppCompatDelegate.create(AppCompatDelegate.java:193) 
E/AndroidRuntime: at android.support.v7.app.AppCompatDelegate.create(AppCompatDelegate.java:173) 
E/AndroidRuntime: at android.support.v7.app.AppCompatActivity.getDelegate(AppCompatActivity.java:511) 
E/AndroidRuntime: at android.support.v7.app.AppCompatActivity.onCreate(AppCompatActivity.java:71) 
E/AndroidRuntime: at .MainActivity.onCreate(MainActivity.java:29) 
E/AndroidRuntime: at android.app.Activity.performCreate(Activity.java:5104) 
E/AndroidRuntime: at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1092) 
E/AndroidRuntime: at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2148) 
E/AndroidRuntime: at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2254) 
E/AndroidRuntime: at android.app.ActivityThread.access$600(ActivityThread.java:141) 
E/AndroidRuntime: at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234) 
E/AndroidRuntime: at android.os.Handler.dispatchMessage(Handler.java:99) 
E/AndroidRuntime: at android.os.Looper.loop(Looper.java:137) 
E/AndroidRuntime: at android.app.ActivityThread.main(ActivityThread.java:5069) 
E/AndroidRuntime: at java.lang.reflect.Method.invokeNative(Native Method) 
E/AndroidRuntime: at java.lang.reflect.Method.invoke(Method.java:511) 
E/AndroidRuntime: at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793) 
E/AndroidRuntime: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560) 
E/AndroidRuntime: at dalvik.system.NativeStart.main(Native Method) 
I'm really confused about what it can be, I read and can't get to the error:
My app:gradle is this:
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "24.0.2"
defaultConfig {
applicationId "me.me2.com.myapp"
minSdkVersion 15
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.4.0'
compile 'com.android.support:design:23.4.0'
compile 'com.android.support:recyclerview-v7:23.4.0'
compile 'com.android.support:cardview-v7:23.4.0'
compile 'com.google.firebase:firebase-storage:9.4.0'
compile 'com.google.firebase:firebase-database:9.4.0'
compile 'com.google.firebase:firebase-auth:9.4.0'
compile 'com.firebaseui:firebase-ui-database:0.4.4'
compile 'com.squareup.picasso:picasso:2.5.2'
}
apply plugin: 'com.google.gms.google-services'
Here is my style folder:
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">#color/colorPrimary</item>
<item name="colorPrimaryDark">#color/colorPrimaryDark</item>
<item name="colorAccent">#color/colorAccent</item>
</style>
<style name="AppTheme.NoActionBar">
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
</style>
<style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar" />
<style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light" />
<style name="Divider">
<item name="android:layout_width">match_parent</item>
<item name="android:layout_height">1dp</item>
<item name="android:background">?android:attr/listDivider</item>
</style>
</resources>
And my mainactivity.class if needed:
public class MainActivity extends AppCompatActivity {
VideoView videoView;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
// VideoView
videoView = (VideoView) findViewById(R.id.videoview);
videoView.setVideoURI(Uri.parse("android.resource://"+getPackageName() + "/" +R.raw.video));
videoView.requestFocus();
/**
* Loop
*/
videoView.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {
#Override
public void onPrepared(MediaPlayer mp) {
videoView.start();
mp.setLooping(true);
}
});
}
public void Login(View view) {
Intent intent = new Intent(this, FragmentMain.class);
startActivity(intent);
// finish();
}
public void Registro(View view) {
Intent intent = new Intent(this, Registro.class);
startActivity(intent);
}
#Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.menu_main, menu);
return true;
}
#Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
//noinspection SimplifiableIfStatement
if (id == R.id.action_settings) {
return true;
}
return super.onOptionsItemSelected(item);
}
}
Thanks.

IF you're using Gradle Plugin 2.0, you need to make changes in your gradle:
// Gradle Plugin 2.0+
android {
defaultConfig {
vectorDrawables.useSupportLibrary = true
}
}
If you are using Gradle 1.5 you’ll use instead of previus:
// Gradle Plugin 1.5
android {
defaultConfig {
// Stops the Gradle plugin's automatic rasterization of vectors
generatedDensities = []
}
// Flag to tell aapt to keep the attribute ids around
// This is handled for you by the 2.0+ Gradle Plugin
aaptOptions {
additionalParameters "--no-version-vectors"
}
}
Check also: Update Android Support Library to 23.2.0 cause error: XmlPullParserException Binary XML file line #17<vector> tag requires viewportWidth > 0.
Android Support Library Ref.: Support Vector Drawables and Animated Vector Drawables.
Also update Android Support dependencies from
compile 'com.android.support:appcompat-v7:23.4.0'
compile 'com.android.support:design:23.4.0'
compile 'com.android.support:recyclerview-v7:23.4.0'
compile 'com.android.support:cardview-v7:23.4.0'
to
compile 'com.android.support:appcompat-v7:24.2.0'
compile 'com.android.support:design:24.2.0'
compile 'com.android.support:recyclerview-v7:24.2.0'
compile 'com.android.support:cardview-v7:24.2.0'
as you're already using build-tools in version of 24.0.2.

If any of the other solutions does not work, you can add this line in your Activity
static {
AppCompatDelegate.setCompatVectorFromResourcesEnabled(true);
}
and of course, update your gradle and appcompat to the latest versions. This worked in my case.

None of these worked for me. But this did:
Change
android:src="#drawable/your_drawable"
to
app:srcCompat="#drawable/your_drawable"

I ran into this issue in Xamarin.Android with Xamarin.Android.Support.Design 24.0.2. Here is how I solved it:
Added the following line to my Application class OnCreate:
AppCompatDelegate.CompatVectorFromResourcesEnabled = true;
Replaced:
var upArrow = ContextCompat.GetDrawable(this, Resource.Drawable.abc_ic_ab_back_material);
With:
var upArrow = ResourcesCompat.GetDrawable(Resources, Resource.Drawable.abc_ic_ab_back_material, null);

Since this page is the first result of google android.content.res.Resources$NotFoundException: File res/drawable/, I want to share that this exception might caused by your foo.xml contains improper code.
e.g. foo.xml:
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="#android:id/background">
<shape>
<size android:height="#android:style/Widget.ProgressBar.Horizontal" />
<corners android:radius="5dip" />
<gradient
android:startColor="#000000"
android:centerY="0.75"
android:angle="270"
/>
</shape>
</item>
</layer-list>
This xml contains <size android:height="#android:style/Widget.ProgressBar.Horizontal" /> which compiled successfully but throws exception at Runtime, vary in different app.

use like this in your Activity:
public class MainActivity extends AppCompatActivity {
static {
AppCompatDelegate.setCompatVectorFromResourcesEnabled(true);
}
...
}
and this in your build.gradle :
android {
...
defaultConfig {
....
vectorDrawables.useSupportLibrary = true
}
}
and in your xml:
app:srcCompat="#drawable/your_icon"

For me the issue was while running the app on Kitkat version I got this runtime crash.
Issue:
android {
compileSdkVersion 28
defaultConfig {
//Change this to true to enable multidex support for Kitkat
multiDexEnabled true
vectorDrawables.useSupportLibrary = true
}
Solution:
//comment the line of vector support
android {
//Change this to true to enable multidex support for Kitkat
multiDexEnabled true
//vectorDrawables.useSupportLibrary = true
}

Ok, i just solved my problem, the problem was my gradle outdated and my sdk , so if anyone is running with this problem just do this steps
1.- Make sure your libs are updated as piotrek1543 says above
2.- Update your sdk if is necesary
3.- Update your gradle files (VERY IMPORTANT)
just go to the project gradle and add this
classpath 'com.android.tools.build:gradle:2.1.0'
then go to your app project > app > graddle > graddlewrapper.properties and add
distributionUrl=https://services.gradle.org/distributions/gradle-2.10-all.zip
4.- change your compile compileSdkVersion to 24
and your buildToolsVersion "24.0.2" (MAKE SURE YOUR DEPENDENCES ARE UP TO DATE WITH THE SDK)
Have fun

I have tried all solutions mentioned above. Nothing worked for me. The only thing worked for me is very simple is to update all support libraries to latest version as this bug has been fixed in it. So i simple did the below thing in gradle file; updated SDK and support to 25.
android {
compileSdkVersion 25
buildToolsVersion "25"
defaultConfig {
targetSdkVersion 25
}
}
In dependencies
compile 'com.android.support:appcompat-v7:25.1.0'
compile 'com.android.support:design:25.1.0'
compile 'com.android.support:recyclerview-v7:25.1.0'

Not specifically related to your question, but maybe can solve this problem for all that find themselves here while searching for that error.
For me was the problem with SVG file that I have imported into my project. One of the paths in XML has empty pathData and that was causing the crash on some devices like Pixel XL, Samsung Galaxy S7,...
So double check imported XML for an image if you are using SVG as your image source.

I had this problem.
In your Application class, in the onCreate() method, add:
AppCompatDelegate.setCompatVectorFromResourcesEnabled(true);
... and also use AppCompatImageView instead of ImageView.
Ex :
BaseApplication.class :
public class BaseApplication extends Application {
#Override
public void onCreate() {
super.onCreate();
//Your other code here...
AppCompatDelegate.setCompatVectorFromResourcesEnabled(true);
}
}
XML :
<androidx.appcompat.widget.AppCompatImageView
android:id="#+id/yourIvId"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />

In my case, the issue was about using vector drawable.
The spec of the test device was Huawei EVA-L19, Android: Marshmallow
Using srcCompat instead of src resolved my problem.

In my case, the problem was wrong super-type. I added image view dynamically, and used ImageView instead of AppCompatImageView. Choosing the right super class solved the issue.

I tried all the answers above but no success because of clarity most of the time.
Just do this:
In the launch_background.xml file, replace mipmap with drawable
Copy the icon image that should be your app icon and paste it in the drawable folder
At the end the launch_background.xml file should look like below.
<?xml version="1.0" encoding="utf-8"?>
<!-- Modify this file to customize your launch splash screen -->
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="#color/blue" />
<!-- You can insert your own image assets here -->
<item>
<bitmap android:gravity="center" android:src="#drawable/ic_launcher" />
</item>
</layer-list>

Changing the kotlin-stdlib dependency from:
implementation "org.jetbrains.kotlin:kotlin-stdlib-jre7:1.2.0"
to
implementation "org.jetbrains.kotlin:kotlin-stdlib:1.2.0"
fixed the error.

in my case the XML contained android:endX that supports from 24 and up.

If you are using ?attr inside your drawable, this could be the reason of error.
consider replacing it with Vector Drawable so it can be used in all android versions:
Replace
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<shape android:shape="rectangle">
<solid android:color="?attr/navigationIconColor" />
</shape>
</item>
</selector>
With:
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="37dp"
android:height="5dp"
android:viewportWidth="37"
android:viewportHeight="5">
<path
android:pathData="M2.5,0h32C35.9,0 37,1.1 37,2.5l0,0C37,3.9 35.9,5 34.5,5h-32C1.1,5 0,3.9 0,2.5l0,0C0,1.1 1.1,0 2.5,0z"
android:fillColor="?attr/navigationIconColor"/>
</vector>

The above methods didn’t work for me. I solved it by adding image of every size and used android:src as well it worked.
See the answer here https://stackoverflow.com/a/64537207/11669081

for running the app on Kitkat version make use of VectorDrawableCompat like below
ivBg.setImageDrawable(VectorDrawableCompat.create(resources, R.drawable.ic_bg_minicash_single,context?.theme))
No need to change ImageView into AppCompatImageView explicitly AppCompatActivity will automatically convert it.

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'

RuntimeException when clicking on EditText

I have a release Android App that goes smooth on a Nexus 5X running Android 6.0.1. and on a Samsung 5 running Android 5.0.
However, on other devices weird exceptions rise when double clicking or long clicking any EditText.
This is the track on an Alcatel OneTouch (Android 5.1):
E/AndroidRuntime: FATAL EXCEPTION: main
Process: es.solbyte.ociohoteles, PID: 18176
android.view.InflateException: Binary XML file line #17: Error inflating class TextView
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:763)
at android.view.LayoutInflater.inflate(LayoutInflater.java:482)
at android.view.LayoutInflater.inflate(LayoutInflater.java:414)
at android.view.LayoutInflater.inflate(LayoutInflater.java:365)
at android.widget.Editor$ActionPopupWindow.initContentView(Editor.java:3047)
at android.widget.Editor$PinnedPopupWindow.<init>(Editor.java:2302)
at android.widget.Editor$ActionPopupWindow.<init>(Editor.java:3019)
at android.widget.Editor$ActionPopupWindow.<init>(Editor.java:3019)
at android.widget.Editor$HandleView.showActionPopupWindow(Editor.java:3422)
at android.widget.Editor$InsertionHandleView.showWithActionPopup(Editor.java:3672)
at android.widget.Editor$InsertionPointCursorController.showWithActionPopup(Editor.java:3929)
at android.widget.Editor.performLongClick(Editor.java:900)
at android.widget.TextView.performLongClick(TextView.java:9104)
at android.view.View$CheckForLongPress.run(View.java:20236)
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:5631)
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:959)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:754)
Caused by: java.lang.ArrayIndexOutOfBoundsException: length=15; index=1570
at android.content.res.StringBlock.get(StringBlock.java:65)
at android.content.res.XmlBlock$Parser.getPooledString(XmlBlock.java:458)
at android.content.res.TypedArray.loadStringValueAt(TypedArray.java:1003)
at android.content.res.TypedArray.getString(TypedArray.java:188)
at android.widget.TextView.<init>(TextView.java:1042)
at android.widget.TextView.<init>(TextView.java:660)
at android.support.v7.widget.AppCompatTextView.<init>(AppCompatTextView.java:60)
at android.support.v7.widget.AppCompatTextView.<init>(AppCompatTextView.java:56)
at android.support.v7.app.AppCompatViewInflater.createView(AppCompatViewInflater.java:103)
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:725)
at android.view.LayoutInflater.inflate(LayoutInflater.java:482) 
at android.view.LayoutInflater.inflate(LayoutInflater.java:414) 
at android.view.LayoutInflater.inflate(LayoutInflater.java:365) 
at android.widget.Editor$ActionPopupWindow.initContentView(Editor.java:3047) 
at android.widget.Editor$PinnedPopupWindow.<init>(Editor.java:2302) 
at android.widget.Editor$ActionPopupWindow.<init>(Editor.java:3019) 
at android.widget.Editor$ActionPopupWindow.<init>(Editor.java:3019) 
at android.widget.Editor$HandleView.showActionPopupWindow(Editor.java:3422) 
at android.widget.Editor$InsertionHandleView.showWithActionPopup(Editor.java:3672) 
at android.widget.Editor$InsertionPointCursorController.showWithActionPopup(Editor.java:3929) 
at android.widget.Editor.performLongClick(Editor.java:900) 
at android.widget.TextView.performLongClick(TextView.java:9104) 
at android.view.View$CheckForLongPress.run(View.java:20236) 
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:5631) 
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:959) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:754) 
And this is the track on an ZTE Kis II Max (Android 4.4.2):
06-29 16:37:44.361 12852-12852/? E/AndroidRuntime: FATAL EXCEPTION: main
Process: es.solbyte.ociohoteles, PID: 12852
android.view.InflateException: Binary XML file line #17: Error inflating class TextView
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:713)
at android.view.LayoutInflater.inflate(LayoutInflater.java:469)
at android.view.LayoutInflater.inflate(LayoutInflater.java:397)
at android.view.LayoutInflater.inflate(LayoutInflater.java:353)
at android.widget.Editor$ActionPopupWindow.initContentView(Editor.java:2973)
at android.widget.Editor$PinnedPopupWindow.<init>(Editor.java:2268)
at android.widget.Editor$ActionPopupWindow.<init>(Editor.java:2946)
at android.widget.Editor$ActionPopupWindow.<init>(Editor.java:2946)
at android.widget.Editor$HandleView.showActionPopupWindow(Editor.java:3166)
at android.widget.Editor$SelectionModifierCursorController.initHandles(Editor.java:3690)
at android.widget.Editor$SelectionModifierCursorController.show(Editor.java:3661)
at android.widget.Editor$SelectionActionModeCallback.onCreateActionMode(Editor.java:2896)
at com.android.internal.policy.impl.PhoneWindow$DecorView$ActionModeCallbackWrapper.onCreateActionMode(PhoneWindow.java:2811)
at android.support.v7.view.SupportActionModeWrapper$CallbackWrapper.onCreateActionMode(SupportActionModeWrapper.java:155)
at android.support.v7.app.AppCompatDelegateImplV7$ActionModeCallbackWrapperV7.onCreateActionMode(AppCompatDelegateImplV7.java:1742)
at android.support.v7.app.AppCompatDelegateImplV7.startSupportActionModeFromWindow(AppCompatDelegateImplV7.java:802)
at android.support.v7.app.AppCompatDelegateImplV7.startSupportActionMode(AppCompatDelegateImplV7.java:696)
at android.support.v7.app.AppCompatDelegateImplV14$AppCompatWindowCallbackV14.startAsSupportActionMode(AppCompatDelegateImplV14.java:187)
at android.support.v7.app.AppCompatDelegateImplV14$AppCompatWindowCallbackV14.onWindowStartingActionMode(AppCompatDelegateImplV14.java:171)
at com.android.internal.policy.impl.PhoneWindow$DecorView.startActionMode(PhoneWindow.java:2432)
at com.android.internal.policy.impl.PhoneWindow$DecorView.startActionModeForChild(PhoneWindow.java:2419)
at android.view.ViewGroup.startActionModeForChild(ViewGroup.java:689)
at android.view.ViewGroup.startActionModeForChild(ViewGroup.java:689)
at android.view.ViewGroup.startActionModeForChild(ViewGroup.java:689)
at android.view.ViewGroup.startActionModeForChild(ViewGroup.java:689)
at android.view.ViewGroup.startActionModeForChild(ViewGroup.java:689)
at android.view.ViewGroup.startActionModeForChild(ViewGroup.java:689)
at android.view.ViewGroup.startActionModeForChild(ViewGroup.java:689)
at android.view.ViewGroup.startActionModeForChild(ViewGroup.java:689)
at android.view.View.startActionMode(View.java:4561)
at android.widget.Editor.startSelectionActionMode(Editor.java:1584)
at android.widget.Editor.performLongClick(Editor.java:877)
at android.widget.TextView.performLongClick(TextView.java:8585)
at android.view.View$CheckForLongPress.run(View.java:18768)
at android.os.Handler.handleCallback(Handler.java:808)
at android.os.Handler.dispatchMessage(Handler.java:103)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:5299)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:829)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:645)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.ArrayIndexOutOfBoundsException: length=15; index=1570
at android.content.res.StringBlock.get(StringBlock.java:65)
at android.content.res.XmlBlock$Parser.getPooledString(XmlBlock.java:458)
at android.content.res.TypedArray.loadStringValueAt(TypedArray.java:721)
at android.content.res.TypedArray.getString(TypedArray.java:125)
at android.widget.TextView.<init>(TextView.java:1002)
at android.support.v7.widget.AppCompatTextView.<init>(AppCompatTextView.java:60)
at android.support.v7.
Is someone able to explain what is this happening? Is it somehow related with the hardware/distribution?
EDIT 1:
Please take into account that this is a big app so I cannot post all places where it is crashing. This is an extract of the very first EditText where the app is crashing.
// LoginActivity.java
public class LoginActivity extends ApiActivity implements
onLoginSuccessListener {
#Bind(R.id.login_field_email)
protected EditText user;
/* OnCreate and other methods... */
#OnTextChanged({R.id.login_field_email, R.id.login_field_password})
public void onAnyFieldChanged() {
loginButton.setEnabled(areFieldFilled());
}
This is the content layout XML file:
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="16dp"
tools:context=".activity.LoginActivity"
tools:showIn="#layout/activity_login">
<LinearLayout
android:id="#+id/login_forms"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/login_brand"
android:orientation="vertical">
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColorHint="#android:color/white">
<EditText
android:id="#+id/login_field_email"
style="#style/EditTextLogin"
android:hint="#string/registration_email"
android:imeOptions="actionNext"
android:inputType="textEmailAddress"/>
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout>
...
</android.support.design.widget.TextInputLayout>
</LinearLayout>
<Button
...
/>
</RelativeLayout>
The styles.xml:
<style name="EditTextLogin" parent="android:Widget.EditText">
<item name="android:fontFamily">sans</item>
<item name="android:textColor">#android:color/white</item>
<item name="android:singleLine">true</item>
<item name="android:maxLines">1</item>
<item name="android:layout_width">match_parent</item>
<item name="android:layout_height">44dp</item>
</style>
The build.gradle files:
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
apply plugin: 'realm-android'
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
applicationId "..."
minSdkVersion 16
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
signingConfigs {
config {
keyAlias '...'
keyPassword '...'
storeFile file('...')
storePassword '...'
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.config
}
debug {
debuggable true
useProguard false
applicationIdSuffix ".debug"
}
}
}
repositories {
mavenCentral()
maven { url "https://jitpack.io" }
maven { url 'https://maven.fabric.io/public' }
maven { url "https://clojars.org/repo/" }
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile('com.crashlytics.sdk.android:crashlytics:2.5.2#aar') {
transitive = true;
}
compile 'com.android.support:appcompat-v7:23.4.0'
compile 'com.android.support:design:23.4.0'
compile 'com.google.android.gms:play-services-gcm:9.0.2'
compile 'com.google.android.gms:play-services-location:9.0.2'
compile 'com.squareup.picasso:picasso:2.5.2'
compile 'com.jakewharton:butterknife:7.0.1'
}
And the manifest:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="es.solbyte.ociohoteles">
<!-- All needed permissions here -->
<application
android:name=".MyApplication"
android:allowBackup="true"
android:fullBackupContent="false"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:supportsRtl="false"
android:theme="#style/Base.AppTheme">
<!-- Login -->
<activity
android:name=".activity.LoginActivity"
android:configChanges="orientation|keyboardHidden|screenSize"
android:label="#string/app_name"
android:launchMode="singleTop"
android:screenOrientation="portrait"
android:theme="#style/Base.AppTheme.Login"/>
</application>
<manifest>
And just in case the BaseApp theme:
<!-- Base -->
<style name="Base.AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<!-- Colours -->
<item name="colorPrimary">#color/primaryColor</item>
<item name="colorPrimaryDark">#color/primaryColor_dark</item>
<item name="colorAccent">#color/accentColor</item>
<item name="android:windowBackground">#color/background_activity</item>
<!-- Fonts -->
<item name="android:fontFamily">sans-serif</item>
</style>
I have same problem with editText
the problem in my case was in my style
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">#color/colorPrimary</item>
<item name="android:fontFamily" tools:targetApi="jelly_bean">sans-serif</item>
<item name="colorPrimaryDark">#color/colorPrimaryDark</item>
<item name="colorAccent">#color/colorAccent</item>
</style>
my problem solved by removing this line of code
<item name="android:fontFamily" tools:targetApi="jelly_bean">sans-serif</item>

Update Android Support Library to 23.2.0 cause error: XmlPullParserException Binary XML file line #17<vector> tag requires viewportWidth > 0

I try to update my Support Library up to 23.2.0 and face this error:
Exception while inflating <vector>
org.xmlpull.v1.XmlPullParserException: Binary XML file line #17<vector> tag requires viewportWidth > 0
at android.support.graphics.drawable.VectorDrawableCompat.updateStateFromTypedArray(VectorDrawableCompat.java:535)
at android.support.graphics.drawable.VectorDrawableCompat.inflate(VectorDrawableCompat.java:472)
at android.support.graphics.drawable.VectorDrawableCompat.createFromXmlInner(VectorDrawableCompat.java:436)
at android.support.v7.widget.AppCompatDrawableManager$VdcInflateDelegate.createFromXmlInner(AppCompatDrawableManager.java:829)
at android.support.v7.widget.AppCompatDrawableManager.loadDrawableFromDelegates(AppCompatDrawableManager.java:303)
at android.support.v7.widget.AppCompatDrawableManager.getDrawable(AppCompatDrawableManager.java:178)
at android.support.v7.widget.AppCompatDrawableManager.getDrawable(AppCompatDrawableManager.java:173)
at android.support.v7.widget.TintTypedArray.getDrawable(TintTypedArray.java:60)
at android.support.v7.widget.Toolbar.<init>(Toolbar.java:254)
at android.support.v7.widget.Toolbar.<init>(Toolbar.java:196)
at java.lang.reflect.Constructor.constructNative(Native Method)
at java.lang.reflect.Constructor.newInstance(Constructor.java:417)
at android.view.LayoutInflater.createView(LayoutInflater.java:594)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:696)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:755)
at android.view.LayoutInflater.inflate(LayoutInflater.java:492)
at android.view.LayoutInflater.inflate(LayoutInflater.java:397)
at android.view.LayoutInflater.inflate(LayoutInflater.java:353)
at android.support.v7.app.AppCompatDelegateImplV7.setContentView(AppCompatDelegateImplV7.java:267)
at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:129)
at com.chotot.vn.v2.activities.MainActivity.onCreate(MainActivity.java:121)
at android.app.Activity.performCreate(Activity.java:5133)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2175)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2261)
at android.app.ActivityThread.access$600(ActivityThread.java:141)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1256)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:5103)
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:737)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
at dalvik.system.NativeStart.main(Native Method)
And
FATAL EXCEPTION: main
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.chotot.vn.dev/com.chotot.vn.v2.activities.MainActivity}: android.view.InflateException: Binary XML file line #13: Error inflating class android.support.v7.widget.Toolbar
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2211)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2261)
at android.app.ActivityThread.access$600(ActivityThread.java:141)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1256)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:5103)
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:737)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
at dalvik.system.NativeStart.main(Native Method)
Caused by: android.view.InflateException: Binary XML file line #13: Error inflating class android.support.v7.widget.Toolbar
at android.view.LayoutInflater.createView(LayoutInflater.java:620)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:696)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:755)
at android.view.LayoutInflater.inflate(LayoutInflater.java:492)
at android.view.LayoutInflater.inflate(LayoutInflater.java:397)
at android.view.LayoutInflater.inflate(LayoutInflater.java:353)
at android.support.v7.app.AppCompatDelegateImplV7.setContentView(AppCompatDelegateImplV7.java:267)
at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:129)
at com.chotot.vn.v2.activities.MainActivity.onCreate(MainActivity.java:121)
at android.app.Activity.performCreate(Activity.java:5133)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2175)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2261)
at android.app.ActivityThread.access$600(ActivityThread.java:141)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1256)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:5103)
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:737)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
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:594)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:696)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:755)
at android.view.LayoutInflater.inflate(LayoutInflater.java:492)
at android.view.LayoutInflater.inflate(LayoutInflater.java:397)
at android.view.LayoutInflater.inflate(LayoutInflater.java:353)
at android.support.v7.app.AppCompatDelegateImplV7.setContentView(AppCompatDelegateImplV7.java:267)
at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:129)
at com.chotot.vn.v2.activities.MainActivity.onCreate(MainActivity.java:121)
at android.app.Activity.performCreate(Activity.java:5133)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2175)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2261)
at android.app.ActivityThread.access$600(ActivityThread.java:141)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1256)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:5103)
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:737)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
at dalvik.system.NativeStart.main(Native Method)
Caused by: android.content.res.Resources$NotFoundException: File res/drawable/abc_ic_ab_back_material.xml from drawable resource ID #0x7f020016
at android.content.res.Resources.loadDrawable(Resources.java:2091)
at android.content.res.Resources.getDrawable(Resources.java:695)
at android.support.v7.widget.TintResources.superGetDrawable(TintResources.java:48)
at android.support.v7.widget.AppCompatDrawableManager.onDrawableLoadedFromResources(AppCompatDrawableManager.java:374)
at android.support.v7.widget.TintResources.getDrawable(TintResources.java:44)
at android.support.v4.content.ContextCompat.getDrawable(ContextCompat.java:323)
at android.support.v7.widget.AppCompatDrawableManager.getDrawable(AppCompatDrawableManager.java:180)
at android.support.v7.widget.AppCompatDrawableManager.getDrawable(AppCompatDrawableManager.java:173)
at android.support.v7.widget.TintTypedArray.getDrawable(TintTypedArray.java:60)
at android.support.v7.widget.Toolbar.<init>(Toolbar.java:254)
at android.support.v7.widget.Toolbar.<init>(Toolbar.java:196)
at java.lang.reflect.Constructor.constructNative(Native Method)
at java.lang.reflect.Constructor.newInstance(Constructor.java:417)
at android.view.LayoutInflater.createView(LayoutInflater.java:594)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:696)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:755)
at android.view.LayoutInflater.inflate(LayoutInflater.java:492)
at android.view.LayoutInflater.inflate(LayoutInflater.java:397)
at android.view.LayoutInflater.inflate(LayoutInflater.java:353)
at android.support.v7.app.AppCompatDelegateImplV7.setContentView(AppCompatDelegateImplV7.java:267)
at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:129)
at com.chotot.vn.v2.activities.MainActivity.onCreate(MainActivity.java:121)
at android.app.Activity.performCreate(Activity.java:5133)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2175)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2261)
at android.app.ActivityThread.access$600(ActivityThread.java:141)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1256)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:5103)
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:737)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
at dalvik.system.NativeStart.main(Native Method)
Caused by: org.xmlpull.v1.XmlPullParserException: Binary XML file line #17: invalid drawable tag vector
at android.graphics.drawable.Drawable.createFromXmlInner(Drawable.java:897)
at android.graphics.drawable.Drawable.createFromXml(Drawable.java:837)
at android.content.res.Resources.loadDrawable(Resources.java:2087)
at android.content.res.Resources.getDrawable(Resources.java:695)
at android.support.v7.widget.TintResources.superGetDrawable(TintResources.java:48)
at android.support.v7.widget.AppCompatDrawableManager.onDrawableLoadedFromResources(AppCompatDrawableManager.java:374)
at android.support.v7.widget.TintResources.getDrawable(TintResources.java:44)
at android.support.v4.content.ContextCompat.getDrawable(ContextCompat.java:323)
at android.support.v7.widget.AppCompatDrawableManager.getDrawable(AppCompatDrawableManager.java:180)
at android.support.v7.widget.AppCompatDrawableManager.getDrawable(AppCompatDrawableManager.java:173)
at android.support.v7.widget.TintTypedArray.getDrawable(TintTypedArray.java:60)
at android.support.v7.widget.Toolbar.<init>(Toolbar.java:254)
at android.support.v7.widget.Toolbar.<init>(Toolbar.java:196)
at java.lang.reflect.Constructor.constructNative(Native Method)
at java.lang.reflect.Constructor.newInstance(Constructor.java:417)
at android.view.LayoutInflater.createView(LayoutInflater.java:594)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:696)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:755)
at android.view.LayoutInflater.inflate(LayoutInflater.java:492)
at android.view.LayoutInflater.inflate(LayoutInflater.java:397)
at android.view.LayoutInflater.inflate(LayoutInflater.java:353)
at android.support.v7.app.AppCompatDelegateImplV7.setContentView(AppCompatDelegateImplV7.java:267)
at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:129)
at com.chotot.vn.v2.activities.MainActivity.onCreate(MainActivity.java:121)
at android.app.Activity.performCreate(Activity.java:5133)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2175)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2261)
at android.app.ActivityThread.access$600(ActivityThread.java:141)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1256)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:5103)
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:737)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
at dalvik.system.NativeStart.main(Native Method)
My activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<fragment
android:id="#+id/f_actionbar"
android:name="com.chotot.vn.fragments.ActionBarFragment"
android:layout_width="fill_parent"
android:layout_height="wrap_content" />
<android.support.v7.widget.Toolbar
android:id="#+id/main_tool_bar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:layout_alignParentTop="true"
android:background="#color/action_bar_bg">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<include
android:id="#+id/main_action_bar_layout"
layout="#layout/layout_actionbar_custom_search"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:layout_gravity="top" />
<LinearLayout
android:id="#+id/main_action_bar_layout_content"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#id/main_action_bar_layout"
android:orientation="vertical" />
</RelativeLayout>
</android.support.v7.widget.Toolbar>
<FrameLayout
android:id="#+id/layout_content"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="#id/main_tool_bar" />
</RelativeLayout>
How can I fix it?
Use this code in your build.gradle file
//for Gradle Plugin 2.0+
android {
defaultConfig {
vectorDrawables.useSupportLibrary = true
}
}
If you are using Gradle 1.5 you’ll instead use
defaultConfig {
generatedDensities = []
}
// This is handled for you by the 2.0+ Gradle Plugin
aaptOptions {
additionalParameters "--no-version-vectors"
}
I think may be they are using vector draw-able compact underneath in other lib.found here
You can also upgrade to 23.4.0
dependencies {
compile 'com.android.support:appcompat-v7:23.4.0'
compile 'com.android.support:design:23.4.0'
}
and use a flag to manually enable this functionality:
static
{
AppCompatDelegate.setCompatVectorFromResourcesEnabled(true);
}
inside the activity that uses the vectors.
Source: Age of the vectors
Please remove the appcompat gradle(
compile "com.android.support:appcompat-v7:23.2.0")
and replace with support design (compile 'com.android.support:design:23.1.1') this will solve the problem
On pre-lollipop devices you need to create selector to use VectorDrawable elsewhere from ImageView
app:srcCompat="#drawable/your_vector_drawable"
Selector:
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="#drawable/your_vector_drawable" />
</selector>
Then you can pass this selector, e.g. for TextView drawableLeft/drawableRight in xml
<TextView
android:gravity="center_vertical"
android:drawableLeft="#drawable/selector_your_vector_drawable"
android:drawableStart="#drawable/selector_your_vector_drawable"
android:drawableRight="#drawable/selector_your_vector_drawable"
android:drawableEnd="#drawable/selector_your_vector_drawable"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/your_string" />
Instead of ContextCompat.getDrawable , just use AppCompatDrawableManager.get().getDrawable .
This should work on versions higher than 23.+
Using:
compileSdkVersion 24
buildToolsVersion '24.0.1'
I crashed at run time until I removed the line
defaultConfig {
vectorDrawables.useSupportLibrary = true
}
from my application guild.gradle
This appears to confuse the newer version of the SDK
Hope this saves someone else headaches
I fixed this problem by replacing
dependencies {
compile 'com.android.support:appcompat-v7:23.2.0'
compile 'com.android.support:design:23.2.0'
}
with
dependencies {
compile 'com.android.support:appcompat-v7:23.0.1'
compile 'com.android.support:design:23.0.1'
}
A mix of few of the above solutions worked for me. Here is what I did -
Change gradle version from 1.3.0 to 1.5.0 in build.gradle of project like this
classpath 'com.android.tools.build:gradle:1.5.0'
Update below things in build.gradle of app
buildToolsVersion "23.0.2"
Updated Module dependencies from 23.2.0 to 23.4.0:
compile 'com.android.support:appcompat-v7:23.4.0'
compile 'com.android.support:design:23.4.0'
compile 'com.android.support:support-vector-drawable:23.4.0'
compile 'com.android.support:animated-vector-drawable:23.4.0'
Now depending upon the gradle version you're using, use either of the following two snippets.
Since I am using gradle 1.5.0, I used this -
defaultConfig {
generatedDensities = []
}
aaptOptions {
additionalParameters "--no-version-vectors"
}
But if you are using Gradle 2.1.0 use this instead
defaultConfig {
vectorDrawables.useSupportLibrary = true
}
And then you're good to go. I tested it both in xml as well as programmatically. In xml file, I used this in my ImageView -
app:srcCompat="#drawable/anim_droid"
// where droid_anim is an animated-vector file containing set of animations to animate different paths of the SVG file
And to do it programmatically, I used this -
imageView.setImageResource(R.drawable.anim_droid);
Drawable drawable = imageView.getDrawable();
if (drawable instanceof Animatable) {
((Animatable) drawable).start();
}
Hope it helps! Cheers :)
Had the same problem. For me actually upgrading build Tools version helped :
buildToolsVersion "23.0.2"
Face the crash problem on api 19 when update to 23.2.0.
I solved this problem by update the version to 23.2.1.(The latest version when answer this question. Try to update to latest, maybe google has been fixed it)
compile 'com.android.support:appcompat-v7:23.2.1'
compile 'com.android.support:support:23.2.1'.
Make sure you use the latest buildToolsVersion as well (Download from SDK manager if needed).
Sample Gradle:
android {
compileSdkVersion 24
buildToolsVersion "24.0.0"
defaultConfig {
...
vectorDrawables.useSupportLibrary = true
}
dependencies {
...
compile 'com.android.support:appcompat-v7:24.0.0'
...
}
}
In Gradle (gradle:2.1.0):
defaultConfig {
vectorDrawables.useSupportLibrary = true
}
In layout:
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
app:srcCompat="#drawable/you_vector_drawable"/>
I had this problem, but updating to the versions build:grade:
classpath 'com.android.tools.build:gradle:1.5.0'
And:
buildToolsVersion "23.0.2"
Success!
Replace android:src with app:srcCompat
I was supprised by this exact same problem when I built a new version of my app. My dependency to appcompact was set to auto update.
compile 'com.android.support:appcompat-v7:23+'
So as soon as a new version is available (in this case version 23.2.0) it will replace the old one you were building with.
So you can either switch back to the previous version of the appcompat library (Quick fix):
compile 'com.android.support:appcompat-v7:23.1.1'
Or keep the current library version and use Ajinkya's answer as explained by google in version 23.2.0 release note.
If you opt for the later, don't forget to update your gradle build tool to version 1.5.0 or you couldn't use the new parameters like generatedDensities:
classpath 'com.android.tools.build:gradle:1.5.0'
Faced the same issue, this solution fixed it.
In your class just do
public class YourClass extends xxx {
static {
AppCompatDelegate.setCompatVectorFromResourcesEnabled(true);
}
...
}
and also add this in your gradle file if not yet.
defaultConfig {
vectorDrawables.useSupportLibrary = true
}
I have fixed it by setting..
compile 'com.android.support:appcompat-v7:24.1.1'
compile 'com.android.support:design:24.1.1' and buildToolsVersion '24.0.0'
I met this problem too, what I did:
change
compileSdkVersion 24
buildToolsVersion "22.0.1"
to
compileSdkVersion 24
buildToolsVersion "24.0.1"
Insert to build.gradle(Module: app):
android {
defaultConfig {
vectorDrawables.useSupportLibrary = true
}
}
dependencies {
implementation 'com.android.support:appcompat-v7:26.1.0'
}
After, use the code below, in you AppActivity:
AppCompatResources.getDrawable(getContext(), R.drawable.ic_your);
Where available use the app:srcCompat instead android:src and android:background, in XML resource file
I had this problem, but updating to the versions below fixed it for me:
classpath 'com.android.tools.build:gradle:1.5.0'
And:
buildToolsVersion "23.0.2"
Module dependencies:
compile 'com.android.support:appcompat-v7:23.2.0'
compile 'com.android.support:support-v4:23.2.0'
compile 'com.google.android.gms:play-services:8.4.0'
I fixed the problem by replacing
compile 'com.android.support:appcompat-v7:23.2.0'
compile 'com.android.support:support-v4:23.2.0'
with
compile 'com.android.support:appcompat-v7:23.0.2'
compile 'com.android.support:support-v4:23.0.2'
I got this same error in Android Studio 2.2 after I updated my Gradle dependencies to the latest versions but forgot to update the buildToolsVersion of my project.
I changed:
compile 'com.android.support:appcompat-v7:22.2.1'
to:
compile 'com.android.support:appcompat-v7:24.2.1'
While buildToolsVersion remained at "22.0.1" like so:
buildToolsVersion "22.0.1"
So all I did was to update the buildToolsVersion to 24 like so:
buildToolsVersion "24"
since it has previously been download with SDK Manager. So check the latest buildToolsVersion from SDK Manager and see if it matches the dependencies version.
Hope this helps someone.
For me what worked... was removing the 's' from 'https' in the namespace declaration of my xml vector drawable.
That XML came from Google Android documentation itself. You can see in the screenshot that the xmlns is 'http' but in the copy-pastable version below, it's 'https.'
This will stop the rendering errors in the Vector Asset viewer, but you still wont see anything, for reasons I don't get. It's supposed to look like a wrench.
If you right-click the drawables folder and "New --> Vector Asset" you get an android icon asset that works.
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24.0"
android:viewportHeight="24.0">
<path
android:fillColor="#FF000000"
android:pathData="M6,18c0,0.55 0.45,1 1,1h1v3.5c0,0.83 0.67,1.5 1.5,1.5s1.5,-0.67 1.5,-1.5L11,19h2v3.5c0,0.83 0.67,1.5 1.5,1.5s1.5,-0.67 1.5,-1.5L16,19h1c0.55,0 1,-0.45 1,-1L18,8L6,8v10zM3.5,8C2.67,8 2,8.67 2,9.5v7c0,0.83 0.67,1.5 1.5,1.5S5,17.33 5,16.5v-7C5,8.67 4.33,8 3.5,8zM20.5,8c-0.83,0 -1.5,0.67 -1.5,1.5v7c0,0.83 0.67,1.5 1.5,1.5s1.5,-0.67 1.5,-1.5v-7c0,-0.83 -0.67,-1.5 -1.5,-1.5zM15.53,2.16l1.3,-1.3c0.2,-0.2 0.2,-0.51 0,-0.71 -0.2,-0.2 -0.51,-0.2 -0.71,0l-1.48,1.48C13.85,1.23 12.95,1 12,1c-0.96,0 -1.86,0.23 -2.66,0.63L7.85,0.15c-0.2,-0.2 -0.51,-0.2 -0.71,0 -0.2,0.2 -0.2,0.51 0,0.71l1.31,1.31C6.97,3.26 6,5.01 6,7h12c0,-1.99 -0.97,-3.75 -2.47,-4.84zM10,5L9,5L9,4h1v1zM15,5h-1L14,4h1v1z"/>
Both my design and my appcompat-v7 use 23.2.1, and buildToolsVersion 23.0.2.
This just in. The wrench generated by the 'material icons' interface file --> new --> vector asset --> material icon (then click the icon and select wrench) is:
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24.0"
android:viewportHeight="24.0">
<path
android:fillColor="#FF000000"
android:pathData="M22.7,19l-9.1,-9.1c0.9,-2.3 0.4,-5 -1.5,-6.9 -2,-2 -5,-2.4 -7.4,-1.3L9,6 6,9 1.6,4.7C0.4,7.1 0.9,10.1 2.9,12.1c1.9,1.9 4.6,2.4 6.9,1.5l9.1,9.1c0.4,0.4 1,0.4 1.4,0l2.3,-2.3c0.5,-0.4 0.5,-1.1 0.1,-1.4z"/>
</vector>
This online utility did okay by me. Use Chrome. It converts SVG to android vector drawables.
problem was :
/VdcInflateDelegate: Exception while inflating <vector>
solution:
changed compileSdkVersion 23 buildToolsVersion "23.0.2"
to compileSdkVersion 24 buildToolsVersion "24.0.2"
solution code:
compileSdkVersion 24
buildToolsVersion '24.0.1'
using this above code I solved the problem
Just add the following dependancy in your build.gradle. this will fix your problem. I'm using 25.0.2 buildToolsVersion.
compile 'com.android.support:support-vector-drawable:25.3.0'
I changed the FragmentActivity to AppCompatActivity, the problem is solved. My environment is:
compileSdkVersion = 25
buildToolsVersion = "25.0.0"
supportVersion = "25.2.0"
In my case this solution worked:
Use
android:theme="#style/TextLabelWhite"
just like in your xml. Change style parent to your AppTheme style,
like:
<style name="TextLabelWhite" parent="AppTheme">
Even though I have support of vector enabled in my gradle and have the latest version of gradle, build tools, support library and Android studio, I still got the error.
Here a fix for my case:
AppCompatDrawableManager.get().getDrawable(getContext(), R.drawable.drawable_xyz);
to supress the lint warning add this #SuppressLint("RestrictedApi")
try to use :
compile 'com.android.support:design:23.1.1'
instead of:
compile "com.android.support:appcompat-v7:23.2.0"
Also Observed on buildToolsVersion '26.0.2'
Downgrading to buildToolsVersion '25.0.3' worked.
For buildToolsVersion '26.0.2' : Try AppCompat for Widgets
Example : TextView -> android.support.v7.widget.AppCompatTextView
(For older Android Version support)
Also observed on lower end devices when the device is unable to inflate drawables due to memory shortage.(Even though the drawable exists in your res->drawable dir) : Try changing your drawable with less complex ones.

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

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.

Categories

Resources