android - 错误:将 gradle 从 appcompat:1.2.0 更新为 appcompat:1.3.1 时出现“ID 未引用此 Activity 中的视图”
问题描述
我从以下位置更新了 gradle 文件中的组件:
implementation 'androidx.appcompat:appcompat:1.2.0'
至
implementation 'androidx.appcompat:appcompat:1.3.1'
并开始收到这些错误:
Error inflating class fragment
ID does not reference a View inside this Activity
在 onCreateView 期间从 startDestination 片段调用此调用:
navController = Navigation.findNavController(getActivity(), R.id.nav_host_fragment);
当我切换回:
implementation 'androidx.appcompat:appcompat:1.2.0'
问题消失了。有人成功通过此更新管理吗?如果有,步骤是什么?
更新
从 activity_main.xml 请求的 XML
<fragment
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/nav_host_fragment"
android:name="androidx.navigation.fragment.NavHostFragment"
app:navGraph="@navigation/nav_graph"
app:defaultNavHost="true" />
解决方案
推荐阅读
- php - 使用 php 将种子点随机分配给 128 个团队
- python-3.x - 同一个嵌入中的多个结果 | 不和谐.py
- docker - Tomcat Server 导致 CAS SSO Docker Image 失败
- vb.net - 在 vb.net 中将 ISO 时间格式转换为本地日期时间
- python - 根据其他列修改数据框值
- css - 在电子邮件中创建 HTML 表格时,如何在一行上方添加空格,但不能在所有行上方添加空格?
- arrays - 使用参考在函数之间传递值并在删除最低分数后计算分数的平均值。C++
- tensorflow - 如何使用 tensorflow 对象检测 API 计算检测到的对象(在边界框中)的数量
- c# - 当球高速运动时,它有可能穿透桨叶。这肯定会使游戏不那么逼真
- scala - 使用 sbt 在项目目录外创建目标目录