【问题标题】:Error:(2) Attribute "spinnerStyle" has already been defined错误:(2) 属性“spinnerStyle”已被定义
【发布时间】:2016-08-05 09:37:51
【问题描述】:

是否有人熟悉以下问题。

/Users/macpurple8/Desktop/Minto_Purple/Clients/Sanghi/Sanghi 03 03 7pm/app/src/main/res/values/colors.xml
Error:(2) Attribute "spinnerStyle" has already been defined

Error:Execution failed for task ':app:processDebugResources'.
> com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command '/Users/macpurple8/Desktop/adt-bundle-mac-x86_64-20140702/sdk/build-tools/23.0.1/aapt'' finished with non-zero exit value 1

我的项目运行良好。当我添加一个新片段时出现了问题。任何想法,可能是什么问题??

更新

附上代码...

这些是使用的库..

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    testCompile 'junit:junit:4.12'
    compile project(':purpleb2b')
    compile 'com.android.support:appcompat-v7:23.1.1'
    compile 'com.android.support:design:23.1.1'
    compile 'com.android.support:support-v4:23.1.1'
    compile 'com.jakewharton:butterknife:7.0.1'
    compile 'com.android.support:cardview-v7:23.1.1'
    compile 'com.squareup.picasso:picasso:2.5.2'
    compile 'com.thomashaertel:multispinner:0.1.1'
    compile 'com.itextpdf.tool:xmlworker:5.5.8'
    compile 'com.google.android.gms:play-services-gcm:8.4.0'

}

'purpletb2b' 是一个自定义库。其依赖如下

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:appcompat-v7:23.0.1'
    compile 'de.greenrobot:greendao:2.0.0'
    compile 'com.google.code.gson:gson:2.4'
    compile 'me.neavo:volley:2014.12.09'
    compile 'org.apache.httpcomponents:httpmime:4.3.1'
    compile 'org.apache.httpcomponents:httpcore:4.3.1'
    compile 'itext:itext:1.3.1'
    compile 'org.json:json:20151123'
    compile 'com.opencsv:opencsv:3.6'
    compile 'org.apache.httpcomponents:httpclient:4.5'
}

在我的 style.xml 中,我也没有使用“spinnerStyle”。我不确定列出的任何库是否正在使用它。请提出解决方案。

【问题讨论】:

  • 检查您的 xml 文件,可能您已经使用了两次样式标签,或者在您的 styles.xml 中您已经编写了两次样式也发布了您的代码
  • 也发布你的colors.xml
  • @RAVI GADIPUDI - 没有任何名为 spinnerStyle 的颜色。当我单击错误中的那一行时,它会显示颜色页面。但没有指向任何地方!

标签: android


【解决方案1】:

如果您的项目中有多个“SpinnerStyle”定义,则可能会产生该错误。检查您是否使用过任何可能定义相同的库。

【讨论】:

    【解决方案2】:

    签入 attrs.xml 的值

     <declare-styleable name="a">
         <attr name="spinnerStyle" format="string" />  // same attr name
     </declare-styleable>
     <declare-styleable name="b">
         <attr name="spinnerStyle" format="string" />  // same attr name
     </declare-styleable>
    

    上面的代码会引发类似的错误。 最佳实践格式代码如下

    <declare-styleable name="a">
          <attr name="a_spinnerStyle" format="string" />  // same attr name
    </declare-styleable>
    

    在 res 下的任何 XML 文件中都可以看到类似的情况。

    【讨论】:

      【解决方案3】:

      'com.thomashaertel:multispinner:0.1.1' 定义属性&lt;item name="spinnerStyle"&gt; 与您包含的其他库之一一样。

      这个属性也在最新的 android 支持库 (24) 中定义,导致同样的冲突。解决此问题的最佳选择是向 multispinner 库提交拉取请求以更改此属性的名称,或者在项目中包含源代码并自行进行更改。

      【讨论】:

        猜你喜欢
        • 2014-12-20
        • 2016-09-14
        • 2023-04-04
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2015-11-01
        • 1970-01-01
        相关资源
        最近更新 更多