android
runtime_error
ai_generated
true
android.view.InflateException: Binary XML file line #XX: Error inflating class <unknown>
ID: android/layout-inflater-crash-bad-parameter
90%Fix Rate
87%Confidence
1Evidence
2023-01-10First Seen
Version Compatibility
| Version | Status | Introduced | Deprecated | Notes |
|---|---|---|---|---|
| Android 10 (API 29) | active | — | — | — |
| Android 11 (API 30) | active | — | — | — |
| Android 12 (API 31) | active | — | — | — |
| Android 13 (API 33) | active | — | — | — |
Root Cause
A layout XML file contains an invalid attribute, missing custom view, or incompatible resource reference that prevents inflation.
generic中文
布局 XML 文件包含无效属性、缺少自定义视图或不兼容的资源引用,导致无法膨胀。
Official Documentation
https://developer.android.com/reference/android/view/InflateExceptionWorkarounds
-
90% success Inspect the layout XML file at the line number indicated in the error. Look for typos in attribute names, missing namespace declarations (e.g., xmlns:app), or incorrect custom view class names. Example: replace 'android:backgroundTint' with 'app:backgroundTint' if using appcompat.
Inspect the layout XML file at the line number indicated in the error. Look for typos in attribute names, missing namespace declarations (e.g., xmlns:app), or incorrect custom view class names. Example: replace 'android:backgroundTint' with 'app:backgroundTint' if using appcompat.
-
85% success Ensure all custom views are properly declared in the XML with their fully qualified class name (e.g., com.example.MyCustomView instead of MyCustomView).
Ensure all custom views are properly declared in the XML with their fully qualified class name (e.g., com.example.MyCustomView instead of MyCustomView).
-
80% success If using a custom view from a library, verify the library is added as a dependency in build.gradle and the view is not conditionally loaded.
If using a custom view from a library, verify the library is added as a dependency in build.gradle and the view is not conditionally loaded.
中文步骤
检查错误指示行号的布局 XML 文件,查找属性名称拼写错误、缺少命名空间声明(如 xmlns:app)或不正确的自定义视图类名。例如:如果使用 appcompat,将 'android:backgroundTint' 替换为 'app:backgroundTint'。
确保所有自定义视图在 XML 中使用完整限定类名声明(例如 com.example.MyCustomView 而不是 MyCustomView)。
如果使用了库中的自定义视图,请验证该库是否已作为依赖项添加到 build.gradle 中,并且该视图不是条件加载的。
Dead Ends
Common approaches that don't work:
-
90% fail
The error is in the code, not runtime cache; clearing cache doesn't fix invalid XML.
-
95% fail
Reinstallation doesn't change the source code; the same invalid XML will be inflated again.