android
runtime_error
ai_generated
true
android.view.InflateException: Binary XML file line #XX: Binary XML file line #XX: Error inflating class androidx.constraintlayout.widget.ConstraintLayout
ID: android/layout-inflate-error-constraintlayout
88%Fix Rate
85%Confidence
1Evidence
2023-03-15First Seen
Version Compatibility
| Version | Status | Introduced | Deprecated | Notes |
|---|---|---|---|---|
| ConstraintLayout 2.1.4 | active | — | — | — |
| Android Gradle Plugin 8.0.0 | active | — | — | — |
| AndroidX AppCompat 1.6.0 | active | — | — | — |
Root Cause
ConstraintLayout version mismatch or missing dependency in build.gradle, causing layout inflation failure at runtime.
generic中文
ConstraintLayout版本不匹配或build.gradle中缺少依赖项,导致运行时布局膨胀失败。
Official Documentation
https://developer.android.com/reference/androidx/constraintlayout/widget/ConstraintLayoutWorkarounds
-
85% success Add explicit ConstraintLayout dependency in build.gradle: implementation 'androidx.constraintlayout:constraintlayout:2.1.4' and ensure all AndroidX libraries are on same version.
Add explicit ConstraintLayout dependency in build.gradle: implementation 'androidx.constraintlayout:constraintlayout:2.1.4' and ensure all AndroidX libraries are on same version.
-
80% success Downgrade ConstraintLayout to 2.1.3 if using older AGP version, or upgrade AGP to 8.1.0 for compatibility.
Downgrade ConstraintLayout to 2.1.3 if using older AGP version, or upgrade AGP to 8.1.0 for compatibility.
中文步骤
Add explicit ConstraintLayout dependency in build.gradle: implementation 'androidx.constraintlayout:constraintlayout:2.1.4' and ensure all AndroidX libraries are on same version.
Downgrade ConstraintLayout to 2.1.3 if using older AGP version, or upgrade AGP to 8.1.0 for compatibility.
Dead Ends
Common approaches that don't work:
-
Adding ConstraintLayout dependency without specifying version, relying on transitive dependency from AppCompat
65% fail
Transitive version may be outdated or incompatible with other libraries; explicit version needed.
-
Cleaning project and rebuilding without updating dependencies
50% fail
Does not address version mismatch; if dependencies are stale, rebuild repeats same error.