android
runtime_error
ai_generated
true
android.view.InflateException: Binary XML file line #XX: Error inflating class androidx.constraintlayout.widget.ConstraintLayout
ID: android/layout-constraint-layout-inflation-error
85%Fix Rate
85%Confidence
1Evidence
2023-01-20First Seen
Version Compatibility
| Version | Status | Introduced | Deprecated | Notes |
|---|---|---|---|---|
| ConstraintLayout 2.1.4 | active | — | — | — |
| ConstraintLayout 2.2.0 | active | — | — | — |
Root Cause
The ConstraintLayout dependency is missing, version mismatch, or the XML layout contains invalid attributes that prevent inflation.
generic中文
缺少 ConstraintLayout 依赖项、版本不匹配或 XML 布局包含阻止膨胀的无效属性。
Official Documentation
https://developer.android.com/reference/androidx/constraintlayout/widget/ConstraintLayoutWorkarounds
-
90% success Ensure the ConstraintLayout dependency is in build.gradle (Module: app). Example: implementation 'androidx.constraintlayout:constraintlayout:2.1.4' and sync the project.
Ensure the ConstraintLayout dependency is in build.gradle (Module: app). Example: implementation 'androidx.constraintlayout:constraintlayout:2.1.4' and sync the project.
-
80% success Check for version conflicts by running ./gradlew :app:dependencies and ensure no duplicate or incompatible versions of ConstraintLayout are present.
Check for version conflicts by running ./gradlew :app:dependencies and ensure no duplicate or incompatible versions of ConstraintLayout are present.
-
75% success If using a library module, use 'api' instead of 'implementation' to propagate the dependency to the app module.
If using a library module, use 'api' instead of 'implementation' to propagate the dependency to the app module.
中文步骤
确保 build.gradle(模块:app)中有 ConstraintLayout 依赖项。示例:implementation 'androidx.constraintlayout:constraintlayout:2.1.4' 并同步项目。
运行 ./gradlew :app:dependencies 检查版本冲突,确保没有重复或不兼容的 ConstraintLayout 版本。
如果使用库模块,使用 'api' 而不是 'implementation' 将依赖项传播到应用程序模块。
Dead Ends
Common approaches that don't work:
-
70% fail
If the version is incompatible with other libraries or the app module doesn't have the dependency, inflation fails.
-
50% fail
This changes the layout behavior and may break UI design, but doesn't fix the underlying dependency issue.
-
85% fail
If the dependency is missing, rebuilding won't fix the classpath issue.