You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

使用aapt.exe打包APK时出现'Found tag id where item is expected'错误求助

解决aapt.exe编译时"Found tag id where item is expected"错误

问题场景

执行以下aapt编译命令:

"aapt.exe" package -f -m -M "AndroidManifest.xml" -I "android.jar" -S "\res" -J "\RJava" --auto-add-overlay

收到错误提示:

Found tag id where item is expected

排查后定位到values.xml中的这一行代码:

<id name="view_tree_lifecycle_owner"/>

注:使用aapt2.exe时编译正常,但因需求限制必须使用aapt.exe。

解决方案

将values.xml中的<id>标签替换为带类型声明的<item>标签:

<item type="id" name="view_tree_lifecycle_owner"/>

原因说明

旧版aapt.exe不支持独立的<id>标签语法,必须通过<item>标签明确指定资源类型;而新版aapt2.exe已经兼容了简化的<id>写法,因此两者编译表现不同。

内容的提问来源于stack exchange,提问作者zeus

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.13 02:30:53