【我的Android进阶之旅】解决strings.xml格式化占位符错误: Mul
一、错误描述具体错误描述如下所示: D:Code_For_Android_StudioMyGame2048appbuildintermediatesresmergeddebugvaluesvalues.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:AndroidStudiosdkbuild-tools23.0.2aapt.exe'' finished with non-zero exit value 1
Information:BUILD FAILED
Information:Total time: 8.228 secs
二、问题原因我看了下他的strings.xml的源代码,报错的那一行代码是这样写的: <string name="test">游戏%s,作者:%s</string>
检查后发现是string.xml中的 %s 导致编译失败,应该把%s 改成%1$s的形式。 三、解决错误将 <string name="test">游戏%s,作者:%s</string>
改成 <string name="test">游戏%1$s,作者:%2$s</string>
然后重新编译即可成功编译。 可参考文档:
(编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |