android
runtime_error
ai_generated
true
android.view.InflateException: Binary XML file line #XX: 错误膨胀类 <unknown>
android.view.InflateException: Binary XML file line #XX: Error inflating class <unknown>
ID: android/layout-inflater-crash-bad-parameter
90%修复率
87%置信度
1证据数
2023-01-10首次发现
版本兼容性
| 版本 | 状态 | 引入 | 弃用 | 备注 |
|---|---|---|---|---|
| Android 10 (API 29) | active | — | — | — |
| Android 11 (API 30) | active | — | — | — |
| Android 12 (API 31) | active | — | — | — |
| Android 13 (API 33) | active | — | — | — |
根因分析
布局 XML 文件包含无效属性、缺少自定义视图或不兼容的资源引用,导致无法膨胀。
English
A layout XML file contains an invalid attribute, missing custom view, or incompatible resource reference that prevents inflation.
官方文档
https://developer.android.com/reference/android/view/InflateException解决方案
-
检查错误指示行号的布局 XML 文件,查找属性名称拼写错误、缺少命名空间声明(如 xmlns:app)或不正确的自定义视图类名。例如:如果使用 appcompat,将 'android:backgroundTint' 替换为 'app:backgroundTint'。
-
确保所有自定义视图在 XML 中使用完整限定类名声明(例如 com.example.MyCustomView 而不是 MyCustomView)。
-
如果使用了库中的自定义视图,请验证该库是否已作为依赖项添加到 build.gradle 中,并且该视图不是条件加载的。
无效尝试
常见但无效的做法:
-
90% 失败
The error is in the code, not runtime cache; clearing cache doesn't fix invalid XML.
-
95% 失败
Reinstallation doesn't change the source code; the same invalid XML will be inflated again.