開發(fā)過程中,經(jīng)常會引用一些自定義控件咨察,很容易出現(xiàn):
com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException:
Process 'command '/android/sdk/build-tools/23.0.3/aapt''
finished with non-zero exit value 1
Error:(157) Attribute "height" has already been defined
Error:(157) Attribute "background" has already been defined
然后我們就要找到資源被引用的地址,把format="xxx"去掉福青。
舉例:
<declare-styleable name="wepay_input">
<attr name="hint" format="string" />
<attr name="keyText" format="string" />
<attr name="background" format="reference" />
<attr name="height" format="dimension" />
<attr name="enable" format="boolean" />
</declare-styleable>
<declare-styleable name="input_type">
<attr name="text" format="string" />
<attr name="leftText" format="string" />
<attr name="background" format="reference" />
<attr name="height" format="dimension" />
</declare-styleable>
這種情況就會出現(xiàn)多個自定義類的attribute 的名字重復(fù)的問題摄狱,而且有時候也會跟V4或者V7包中的attribute的名字沖突,所以我們一般要修改下面的樣子:
<declare-styleable name="wepay_input">
<attr name="hint" format="string" />
<attr name="keyText" format="string" />
<attr name="background" format="reference" />
<attr name="height" format="dimension" />
<attr name="enable" format="boolean" />
</declare-styleable>
<declare-styleable name="input_type">
<attr name="text" format="string" />
<attr name="leftText" format="string" />
<attr name="background" />
<attr name="height" />
</declare-styleable>