背景:
目前随着androidStudio的版本越来越高,在编译校验的时候,对资源以及资源的格式存在不同的校验。我们经常采用占位符定义在string资源里,但是多个占位存在一些问题,比如%1s %2s,这种在以前老版本是可以通过校验,但是aapt较为严格,
AAPT: warn: multiple substitutions specified in non-positional format; did you mean to add the formatted="false" attribute?
会给出这样的错误提示。
我们这个时候需要将aapt新的编译给关闭,采用以前老的:
在gradle.properity 中新增:
android.enableAapt2=false
2.还有一种也会引起这个问题,在自定义view配置属性的时候.
declare-styleable
<attr name="icon" format="reference"/><!-- 设置默icon--> <attr name="title" format="string"/><!-- 设置默认标题-->
title = typedArray.getString(R.styleable.FX_LabelIconTextView_title); drawable = typedArray.getDrawable(R.styleable.FX_LabelIconTextView_icon);
如果你在获取的时候,出现获取类型异常,也会导致这个问题。这个问题不会在你自己的module暴露出,但是会直接从其他模块检索出来。所以排查也不要遗漏这个问题,
如果真是因为自定义属性问题,只需要改过来,其他modulestring formate将不需要修改。