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

Also available as: JSON · Markdown · 中文
88%Fix Rate
85%Confidence
1Evidence
2023-03-15First Seen

Version Compatibility

VersionStatusIntroducedDeprecatedNotes
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/ConstraintLayout

Workarounds

  1. 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.
  2. 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.

中文步骤

  1. Add explicit ConstraintLayout dependency in build.gradle: implementation 'androidx.constraintlayout:constraintlayout:2.1.4' and ensure all AndroidX libraries are on same version.
  2. 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:

  1. 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.

  2. Cleaning project and rebuilding without updating dependencies 50% fail

    Does not address version mismatch; if dependencies are stale, rebuild repeats same error.