美文网首页
Android Studio出现 finished with n

Android Studio出现 finished with n

作者: wangmf | 来源:发表于2016-04-27 16:02 被阅读387次

开发过程中,经常会引用一些自定义控件,很容易出现:

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>

这种情况就会出现多个自定义类的attribute 的名字重复的问题,而且有时候也会跟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>

相关文章

网友评论

      本文标题:Android Studio出现 finished with n

      本文链接:https://www.haomeiwen.com/subject/rhpcrttx.html