今天有一个Android新手使用strings.xml进行格式化的时候报了占位符错误, Multiple substitutions specified in non-positional format; did you mean to add the formatted=“false” attribute? ,问我该如何解决?
一、错误描述
具体错误描述如下所示:
D:\Code_For_Android_Studio\MyGame2048\app\build\intermediates\res\merged\debug\values\values.xml
Error:(16) Multiple substitutions specified in non-positional format; did you mean to add the formatted="false" attribute?
Error:(16) Unexpected end tag string
Error:Execution failed for task ':app:processDebugResources'.
> com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'F:\AndroidStudio\sdk\build-tools\23.0.2\aapt.exe'' finished with non-zero exit val

本文介绍了在Android开发中遇到的strings.xml文件格式化错误,即Multiple substitutions specified in non-positional format的问题。错误原因是使用了非位置格式的多个替换占位符,解决方案是将%s改为%1$s的格式。通过修改strings.xml,重新编译后问题得到解决。
订阅专栏 解锁全文
12万+

被折叠的 条评论
为什么被折叠?



