android runtime_error ai_generated true

android.view.InflateException: 二进制XML文件第#XX行:膨胀类androidx.constraintlayout.widget.ConstraintLayout时出错

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

其他格式: JSON · Markdown 中文 · English
88%修复率
85%置信度
1证据数
2023-03-15首次发现

版本兼容性

版本状态引入弃用备注
ConstraintLayout 2.1.4 active
Android Gradle Plugin 8.0.0 active
AndroidX AppCompat 1.6.0 active

根因分析

ConstraintLayout版本不匹配或build.gradle中缺少依赖项,导致运行时布局膨胀失败。

English

ConstraintLayout version mismatch or missing dependency in build.gradle, causing layout inflation failure at runtime.

generic

官方文档

https://developer.android.com/reference/androidx/constraintlayout/widget/ConstraintLayout

解决方案

  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.

无效尝试

常见但无效的做法:

  1. Adding ConstraintLayout dependency without specifying version, relying on transitive dependency from AppCompat 65% 失败

    Transitive version may be outdated or incompatible with other libraries; explicit version needed.

  2. Cleaning project and rebuilding without updating dependencies 50% 失败

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