as3.0以上在gradle.properties使用android.enableAapt2=true,as就会提示将要过期了,请设置成 android.enableAapt2=false。当我设置成false啦,这时候编译出错误。
Multiple substitutions specified in non-positional format; did you mean to add the formatted="false"
就是当你的string.xml上含有要格式的字符串比如
<string name="time_picker">%s时</string>
这时候会提示上述错误,因为sdk采用了更加严格的aapt编译,正确的用法如下
If you need to format your strings using String.format(String, Object...) , then you can do so by putting your format arguments in the string resource. For example, with the following resource:
In this example, the format string has two arguments: %1$s is a string and %2$d is a decimal number. You can format the string with arguements from your application like this:
<string name="welcome_messages">Hello, %1$s! You have %2$d new messages.</string>
解决方法:
之前我们用的%s 改为%1$s,如果在一个字符串有两个%s,%s。现在要改为%1$s,%2$s,重新编译没ok了。
如果字符串含有%,而不需要格式化可以有三种方法解决
<string name="time_picker" formatted="false">%s时</string>
<string name="time_picker">%%s时</string>
<string name="time_picker" >\%s时</string>
扫码关注腾讯云开发者
领取腾讯云代金券
Copyright © 2013 - 2025 Tencent Cloud. All Rights Reserved. 腾讯云 版权所有
深圳市腾讯计算机系统有限公司 ICP备案/许可证号:粤B2-20090059 深公网安备号 44030502008569
腾讯云计算(北京)有限责任公司 京ICP证150476号 | 京ICP备11018762号 | 京公网安备号11010802020287
Copyright © 2013 - 2025 Tencent Cloud.
All Rights Reserved. 腾讯云 版权所有