# android.view.InflateException：二进制 XML 文件第 XX 行：二进制 XML 文件第 XX 行：膨胀类 androidx.constraintlayout.widget.ConstraintLayout 时出错。原因：java.lang.IllegalArgumentException：给定的输出必须是与输入不同的布局。不支持并行约束。

- **ID:** `android/layout-inflate-constraintlayout-parallel-constraint`
- **领域:** android
- **类别:** build_error
- **验证级别:** ai_generated
- **修复率:** 85%

## 根因

ConstraintLayout XML 包含冲突或并行的约束（例如，同一视图上同时使用 `layout_constraintLeft_toLeftOf` 和 `layout_constraintRight_toRightOf`，而没有正确的链或偏差），导致布局解析器在膨胀时无法解决。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| ConstraintLayout 2.1.4 | active | — | — |
| ConstraintLayout 2.2.0 | active | — | — |
| AndroidX 1.6.0 | active | — | — |

## 解决方案

1. ```
   In your XML layout, identify the view causing the error and remove one of the parallel constraints. For example, if a TextView has both `app:layout_constraintLeft_toLeftOf="parent"` and `app:layout_constraintRight_toRightOf="parent"`, replace them with `app:layout_constraintStart_toStartOf="parent"` and `app:layout_constraintEnd_toEndOf="parent"` to create a centered horizontal constraint, or use a chain with `app:layout_constraintHorizontal_chainStyle="packed"`.
   ```
2. ```
   Wrap the conflicting view in a nested ConstraintLayout or use a different layout container like LinearLayout to avoid parallel constraints entirely.
   ```

## 无效尝试

- **** — The Layout Editor often generates parallel constraints automatically when dragging; manual removal without understanding the conflict can reintroduce the same error. (80% 失败率)
- **** — The error is a validation issue in the XML, not a library bug; downgrading may hide the symptom but the underlying constraint conflict remains and can cause runtime crashes. (85% 失败率)
