错误提示 : InflateException: Binary XML file line #XX: Error inflating class fragment

在使用android Studio 3.6.1和androidX时遇到InflateException,该错误发生在XML布局中引用多个fragment。解决方案是在引用的Fragment布局文件中添加特定代码。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

报错信息:

android.view.InflateException: Binary XML file line #132: Error inflating class fragment

Caused by: java.lang.IllegalArgumentException: Binary XML file line #132: Duplicate id xxx, tag null, or parent id xxx with another fragment for xxx.xxxFragment

问题背景:

编译工具 : androidStudio 3.6.1

引用版本 : androidX

compileSdkVersion 30
minSdkVersion 19
targetSdkVersion 30

xml布局引用多个fragment,代码如下

<!--子类布局引用的多个fragment中的其中一个-->
<fragment
     android:id="@+id/fragment_file"
     android:name="xxx.xxxFragment"
     android:layout_width="match_parent"
     android:layout_height="wrap_content"
     tools:layout="@layout/layout_attachment_files" />

解决方案:

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值