uni-app 安卓打包失败 昨天能正常打包 今天不行了

uni-app 安卓打包失败 昨天能正常打包 今天不行了

示例代码:

FAILURE: Build failed with an exception.
  • What went wrong:
Execution failed for task ':app:mergeReleaseResources'.

A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
Android resource compilation failed
/srv/.gradle/caches/transforms-2/files-2.1/2a51e8a9f6c076fb72dc1438cdb12968/lib.5plus.base-release/res/values-zh/values-zh.xml:18:5-112: AAPT: warn: multiple substitutions specified in non-positional format; did you mean to add the formatted=“false” attribute?.

操作步骤:

  • 打包安卓app

预期结果:

  • 打包报错

实际结果:

FAILURE: Build failed with an exception.
  • What went wrong:
Execution failed for task ':app:mergeReleaseResources'.

A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
Android resource compilation failed
/srv/.gradle/caches/transforms-2/files-2.1/2a51e8a9f6c076fb72dc1438cdb12968/lib.5plus.base-release/res/values-zh/values-zh.xml:18:5-112: AAPT: warn: multiple substitutions specified in non-positional format; did you mean to add the formatted=“false” attribute?.

bug描述:


更多关于uni-app 安卓打包失败 昨天能正常打包 今天不行了的实战教程也可以访问 https://www.itying.com/category-93-b0.html

3 回复

你好,我也遇到了这个问题,请问你解决了吗?

更多关于uni-app 安卓打包失败 昨天能正常打包 今天不行了的实战教程也可以访问 https://www.itying.com/category-93-b0.html


这都很久了,自己看下打包错误的日志

这是一个典型的Android资源编译错误,主要问题出现在多语言资源文件的字符串格式化上。

错误信息显示在values-zh/values-zh.xml文件的第18-112行,AAPT工具检测到非位置格式的多个字符串替换,建议添加formatted="false"属性。

解决方案:

  1. 清理构建缓存
# 删除gradle缓存目录
rm -rf /srv/.gradle/caches/transforms-2/
# 或清理整个gradle缓存
./gradlew clean
  1. 检查项目中的字符串资源: 查看项目中所有values-zh目录下的strings.xml文件,特别是包含%s%d等格式化占位符的字符串。确保使用位置参数格式:
<!-- 错误示例 -->
<string name="message">欢迎%s使用%s</string>

<!-- 正确示例 -->  
<string name="message">欢迎%1$s使用%2$s</string>
  1. 如果确实需要禁用格式化检查: 在对应的字符串资源中添加formatted="false"属性:
<string name="message" formatted="false">欢迎%s使用%s</string>
回到顶部