Habchi Habchi - 20 days ago 5
Java Question

Android InflateException Binary XML file line #2

I'm trying to get my activity working, but I keep getting the exception below:

02-20 00:27:33.060 30161-30161/com.m2gl.runandshare E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.m2gl.runandshare, PID: 30161
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.m2gl.runandshare/com.m2gl.runandshare.SummaryWorkoutActivity}: android.view.InflateException: Binary XML file line #2: Error inflating class <unknown>
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2739)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2804)
at android.app.ActivityThread.access$900(ActivityThread.java:181)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1473)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:145)
at android.app.ActivityThread.main(ActivityThread.java:6066)
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:1388)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1183)
Caused by: android.view.InflateException: Binary XML file line #2: Error inflating class <unknown>
at android.view.LayoutInflater.createView(LayoutInflater.java:640)
at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:55)
at android.view.LayoutInflater.onCreateView(LayoutInflater.java:689)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:748)
at android.view.LayoutInflater.inflate(LayoutInflater.java:483)
at android.view.LayoutInflater.inflate(LayoutInflater.java:415)
at android.view.LayoutInflater.inflate(LayoutInflater.java:366)
at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:436)
at android.app.Activity.setContentView(Activity.java:2272)
at com.m2gl.runandshare.SummaryWorkoutActivity.onCreate(SummaryWorkoutActivity.java:66)
at android.app.Activity.performCreate(Activity.java:6368)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1119)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2692)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2804)
at android.app.ActivityThread.access$900(ActivityThread.java:181)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1473)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:145)
at android.app.ActivityThread.main(ActivityThread.java:6066)
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:1388)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1183)
Caused by: java.lang.reflect.InvocationTargetException
at java.lang.reflect.Constructor.newInstance(Native Method)
at java.lang.reflect.Constructor.newInstance(Constructor.java:288)
at android.view.LayoutInflater.createView(LayoutInflater.java:614)
at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:55)
at android.view.LayoutInflater.onCreateView(LayoutInflater.java:689)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:748)
at android.view.LayoutInflater.inflate(LayoutInflater.java:483)
at android.view.LayoutInflater.inflate(LayoutInflater.java:415)
at android.view.LayoutInflater.inflate(LayoutInflater.java:366)
at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:436)
at android.app.Activity.setContentView(Activity.java:2272)
at com.m2gl.runandshare.SummaryWorkoutActivity.onCreate(SummaryWorkoutActivity.java:66)
at android.app.Activity.performCreate(Activity.java:6368)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1119)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2692)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2804)
at android.app.ActivityThread.access$900(ActivityThread.java:181)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1473)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:145)
at android.app.ActivityThread.main(ActivityThread.java:6066)
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:1388)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1183)
Caused by: android.content.res.Resources$NotFoundException: File res/color/secondary_text_dark.xml from drawable resource ID #0x1060005
at android.content.res.Resources.loadDrawableForCookie(Resources.java:3761)
at android.content.res.Resources.loadDrawable(Resources.java:3629)
at android.content.res.TypedArray.getDrawable(TypedArray.java:762)
at android.view.View.<init>(View.java:3991)
at android.view.ViewGroup.<init>(ViewGroup.java:507)
at android.widget.LinearLayout.<init>(LinearLayout.java:199)
at android.widget.LinearLayout.<init>(LinearLayout.java:195)
at android.widget.LinearLayout.<init>(LinearLayout.java:191)
at java.lang.reflect.Constructor.newInstance(Native Method)
at java.lang.reflect.Constructor.newInstance(Constructor.java:288)
at android.view.LayoutInflater.createView(LayoutInflater.java:614)
at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:55)
at android.view.LayoutInflater.onCreateView(LayoutInflater.java:689)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:748)
at android.view.LayoutInflater.inflate(LayoutInflater.java:483)
at android.view.LayoutInflater.inflate(LayoutInflater.java:415)
at android.view.LayoutInflater.inflate(LayoutInflater.java:366)
at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:436)
at android.app.Activity.setContentView(Activity.java:2272)
at com.m2gl.runandshare.SummaryWorkoutActivity.onCreate(SummaryWorkoutActivity.java:66)
at android.app.Activity.performCreate(Activity.java:6368)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1119)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2692)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2804)
at android.app.ActivityThread.access$900(ActivityThread.java:181)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1473)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:145)
at android.app.ActivityThread.main(ActivityThread.java:6066)
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:1388)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1183)
Caused by: org.xmlpull.v1.XmlPullParserException: Binary XML file line #18: <item> tag requires a 'drawable' attribute or child tag defining a drawable
at android.graphics.drawable.StateListDrawable.inflate(StateListDrawable.java:180)
at android.graphics.drawable.Drawable.createFromXmlInner(Drawable.java:1170)
at android.graphics.drawable.Drawable.createFromXml(Drawable.java:1083)
at android.content.res.Resources.loadDrawableForCookie(Resources.java:3745)
at android.content.res.Resources.loadDrawable(Resources.java:3629)
at android.content.res.TypedArray.getDrawable(TypedArray.java:762)
at android.view.View.<init>(View.java:3991)
at android.view.ViewGroup.<init>(ViewGroup.java:507)
at android.widget.LinearLayout.<init>(LinearLayout.java:199)
at android.widget.LinearLayout.<init>(LinearLayout.java:195)
at android.widget.LinearLayout.<init>(LinearLayout.java:191)
at java.lang.reflect.Constructor.newInstance(Native Method)
at java.lang.reflect.Constructor.newInstance(Constructor.java:288)
at android.view.LayoutInflater.createView(LayoutInflater.java:614)
at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:55)
at android.view.LayoutInflater.onCreateView(LayoutInflater.java:689)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:748)
at android.view.LayoutInflater.inflate(LayoutInflater.java:483)
at android.view.LayoutInflater.inflate(LayoutInflater.java:415)
at android.view.LayoutInflater.inflate(LayoutInflater.java:366)
at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:436)
at android.app.Activity.setContentView(Activity.java:2272)
at com.m2gl.runandshare.SummaryWorkoutActivity.onCreate(SummaryWorkoutActivity.java:66)
at android.app.Activity.performCreate(Activity.java:6368)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1119)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2692)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2804)
at android.app.ActivityThread.access$900(ActivityThread.java:181)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1473)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:145)
at android.app.ActivityThread.main(ActivityThread.java:6066)
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:1388)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1183)


I know that this exception is about my layout XML file, I also know that a common problem is using big sized images and getting an out of memory problem, but I use xml files for my icons and they are so small.
Since my layout is very big here's a link to a Gist with the layout code: Layout Code

Answer

i find out that the background of my lineraLayout doesn't really support colors as a path android:color... I just changed it to my local colors file using @colors/.. and everything worked just like a charm. Thanks