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

执行expo run:android遇AAPT资源重复定义错误求助

Android构建失败问题排查(Expo + React Native)

问题描述

执行expo run:android时构建失败,报错信息如下:

  • What went wrong:
    Execution failed for task ':app:mergeDebugResources'.

A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade

Android resource compilation failed
/Users/joel/Developer/dnp/android/app/build/intermediates/incremental/mergeDebugResources/merged.dir/values/values.xml:7014: AAPT: error: duplicate value for resource 'attr/show_buffering' with config ''.
/Users/joel/Developer/dnp/android/app/build/intermediates/incremental/mergeDebugResources/merged.dir/values/values.xml:7014: AAPT: error: resource previously defined here.
/Users/joel/Developer/dnp/android/app/build/intermediates/incremental/mergeDebugResources/merged.dir/values/values.xml: AAPT: error: file failed to compile.

expo run:ios可正常构建运行,修改build.gradle中的minSdkVersion等参数后问题仍未解决。

当前环境版本:

  • react-native@0.64.3
  • expo@44.0.6

解决方案建议

  1. 定位重复依赖库
    该报错属于资源重复定义,大概率是两个第三方库都声明了show_buffering自定义属性。可通过以下方式排查:
  • 执行./gradlew app:dependencies生成依赖树,搜索包含该属性的相关库(优先检查视频播放类、媒体类库)。
  • 查看项目中引入的第三方库文档,确认哪些库会定义缓冲相关的资源属性。
  1. 排除重复依赖
    找到冲突库后,在build.gradle中用exclude语法移除其中一个库的重复资源模块,示例:
implementation('冲突库坐标') {
    exclude group: 'com.example', module: '重复资源模块' // 替换为实际冲突模块信息
}
  1. 清理构建缓存
    执行以下命令清理残留的旧资源文件,避免缓存干扰:
./gradlew clean
rm -rf android/app/build
rm -rf .expo

清理完成后重新执行expo run:android。

  1. 检查本地资源文件
    确认项目android/app/src/main/res/values/目录下的自定义attrs.xml文件,是否重复定义了show_buffering属性,若有则删除重复项。

  2. 调整库版本兼容性
    若为版本不兼容导致的重复定义,尝试升级/降级冲突库到与当前Expo、React Native版本兼容的稳定版本。


内容的提问来源于stack exchange,提问作者Joël

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.21 11:54:21