Android InflateException二进制XML文件行#2

学向勤中得,萤窗万卷书。这篇文章主要讲述Android InflateException二进制XML文件行#2相关的知识,希望能为你提供帮助。
我正在尝试让我的活动正常运行,但我不断收到以下异常:

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)

我知道这个例外是关于我的布局XML文件,我也知道一个常见的问题是使用大尺寸图像并出现内存不足问题,但我使用xml文件作为我的图标,它们非常小。由于我的布局非常大,这里是一个带有布局代码的Gist的链接:Layout Code
答案【Android InflateException二进制XML文件行#2】我发现我的LinearLayout的背景并不真正支持颜色作为路径android:color ...我只是使用@ colors / ..将它改为我的本地颜色文件,一切都像魅力一样。谢谢

    推荐阅读