gpt4 book ai didi

java - Android InflateException 二进制 XML 文件第 2 行

转载 作者:行者123 更新时间:2023-12-01 21:48:43 24 4
gpt4 key购买 nike

我正在尝试让我的 Activity 正常运行,但我不断收到以下异常:

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

最佳答案

我发现我的 LinearLayout 的背景并不真正支持颜色作为路径 android:color...我只是使用 @colors/.. 将其更改为我的本地颜色文件。一切都像魅力一样工作。谢谢

关于java - Android InflateException 二进制 XML 文件第 2 行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35517118/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com