Android Studio出现 finished with non-zero exit value 1

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

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>
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

  • Android 自定义View的各种姿势1 Activity的显示之ViewRootImpl详解 Activity...
    passiontim阅读 176,523评论 25 709
  • Correctness AdapterViewChildren Summary: AdapterViews can...
    MarcusMa阅读 12,879评论 0 6
  • afinalAfinal是一个android的ioc,orm框架 https://github.com/yangf...
    passiontim阅读 15,785评论 2 45
  • 秋风赋 三锁寒风悲莫凉,冬未至,深秋院里黄叶凋,花落人渐瘦,欲饮浊酒忘忧心,何人繁伤为痴怨。 抚栏望江南,泸州苇草...
    秋音南客阅读 5,222评论 0 3
  • "wifi密码多少啊" "你生日" "哦"(暗爽) ****✘ ********✘ "怎么不对啊" "不可能,肯定...
    102222阅读 1,454评论 0 0

友情链接更多精彩内容