【问题标题】:Attribute ”rippleColor“ has already been defined属性“rippleColor”已被定义
【发布时间】:2015-11-01 09:54:31
【问题描述】:

我正在尝试使用 MaterialDesignSupport lib 和 MaterialDesignLib (gitHub) 在同一个项目中

Gradle 依赖项:

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    compile 'com.github.navasmdc:MaterialDesign:1.5@aar'
    compile 'com.android.support:design:22.2.0'
    compile files('MaterialDesign/libs/nineoldandroids-2.4.0.jar') //that jar was missing from some reason
}

但我得到Error:(1) Attribute "rippleColor" has already been defined。 根据this answer attr rippleColor 在项目中被多次提及,我应该重命名它但是包含 attr 的文件在 build 文件夹下,它每次都会重新生成,所以我不能重命名它。有没有办法重命名构建文件或解决这个问题?

【问题讨论】:

    标签: java android android-studio gradle material-design


    【解决方案1】:

    您的应用中有两个不同的 rippleColor 定义,因此您将无法编译它,因为这些定义可能是在您使用的不同库中构建的。

    我认为解决它的唯一方法是从其中一个库中复制您需要的代码,并避免复制 rippleColor 定义。

    【讨论】:

      【解决方案2】:

      替换compile 'com.github.navasmdc:MaterialDesign:1.5@aar'

      compile 'com.github.vajro:MaterialDesignLibrary:1.6'

      并添加

      repositories {
          maven { url "https://jitpack.io" }
      }
      

      注意: 上述 github repo 是 https://github.com/navasmdc/MaterialDesignLibrary 的分叉版本,其中 rippleColor 属性已重命名为 mRippleColor

      或者将原始 repo 克隆到桌面(或某处)并编辑属性并使用它。

      【讨论】:

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