简体   繁体   English

Gradle错误:Android Studio中“属性“ rippleColor”已定义”

[英]Gradle error: “Attribute ”rippleColor“ has already been defined” in android studio

So I was trying out the material design support library and when I added the dependency, compiled, and I got this error. 因此,我尝试了材料设计支持库,并在添加依赖项时进行了编译,但出现此错误。 I looked at similar problems and tried their solutions but it would not get fixed so I hope you can help me. 我研究了类似的问题,并尝试了解决方案,但该问题尚未解决,希望您能为我提供帮助。

Here's my logcat: 这是我的日志:

C:\Users\Jan\AndroidStudioProjects\SwagCalculator3\app\build\intermediates\exploded-aar\com.android.support\appcompat-v7\22.2.0\res\values\values.xml
Error:(1) Attribute "rippleColor" has already been defined

and here is my build.gradle: 这是我的build.gradle:

apply plugin: 'com.android.application'

android {
compileSdkVersion 22
buildToolsVersion "22.0.1"

defaultConfig {
    applicationId "com.raptor.swagcalculator.swagcalculator"
    minSdkVersion 21
    targetSdkVersion 22

}
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}
}

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:design:22.2.0'
compile 'com.android.support:appcompat-v7:22.2.0'
compile 'com.android.support:support-v4:22.2.0'
compile 'com.android.support:cardview-v7:22.2.0'
}

I found the solution here ( https://github.com/navasmdc/MaterialDesignLibrary/issues/289 ). 我在这里找到了解决方案( https://github.com/navasmdc/MaterialDesignLibrary/issues/289 )。 The MaterialDesign Library's rippleColor attritube is replaced with mRippleColor attribute and the compiled library is forked here ( https://github.com/vajro/MaterialDesignLibrary ). MaterialDesign库的波纹颜色attritube被mRippleColor属性替换,编译后的库在此处派生( https://github.com/vajro/MaterialDesignLibrary )。

Adding 新增中

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

} }

and replacing 并替换

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

with

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

in your build.gradle file should solve the issue. 在build.gradle文件中应该可以解决此问题。

I have same issue , after long search I found there are some libraries use the same attribute rippleColor 我有同样的问题,经过长时间搜索后,我发现有些库使用相同的属性rippleColor

Example: 例:

1- Google play service 1- Google Play服务

compile 'com.google.android.gms:play-services:7.8.0'

2- Design Support Library 2-设计支持库

compile 'com.android.support:design:22.2.0'

3- MaterialDesign 3-材料设计

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

Fix this issue 解决这个问题

First to fix this issue replace google play service package (whole package) with specific one you need , please review google site as in Google Wallet there attribute called rippleColor , in my case all I need google maps com.google.android.gms:play-services-maps:7.8.0 首先要解决此问题,将Google Play服务包(整个软件包)替换为您需要的特定包,请查看Google站点,如Google Wallet中的名为rippleColor属性,在我的情况下,我需要所有Google地图com.google.android.gms:play-services-maps:7.8.0

Second you can replace Design Support Library compile com.github.navasmdc:MaterialDesign:1.5@aar with compile 'it.neokree:MaterialNavigationDrawer:1.3.2' , if you need to use navigation drawer only 其次 ,如果仅需要使用导航抽屉,则可以使用compile 'it.neokree:MaterialNavigationDrawer:1.3.2'替换设计支持库compile com.github.navasmdc:MaterialDesign:1.5@aar

I hope this help 我希望这个帮助

It seems that in the projects you are using (your own application + the used libraries) the Attribute named rippleColor is used at least two times. 似乎在您正在使用的项目(您自己的应用程序+使用的库)中,至少两次使用了名为rippleColor的属性。

I'd suggest to check through your xml-s containing colors or any attributes (eg colors.xml , or any other, try search for it in the whole project in your IDE). 我建议您检查包含颜色或任何属性(例如colors.xml或任何其他属性)的xml-s,尝试在IDE的整个项目中进行搜索。

Check whether the mentioned rippleColor is used multiple times. 检查是否多次使用了提到的rippleColor If you have it in your project, rename it! 如果您的项目中有它,请重命名它!

I also met this problem when using Material Design , this is because "rippleColor" conflicts with android support design package. 使用Material Design时 ,我也遇到了这个问题,这是因为“ rippleColor”与android支持设计包冲突。 If you downloaded the module and added it as a dependency, you can solved this problem as follows : 如果下载了该模块并将其添加为依赖项,则可以按以下方式解决此问题:

  1. Press shift-cmd-R to Replace in Path, 按shift-cmd-R键以替换为路径,
  2. Text to find : rippleColor 查找文字:波纹颜色
  3. Replace with : mrippleColor 替换为:mrippleColor
  4. Check "Whole words only(may be faster)" 选中“仅全词(可能会更快)”
  5. press "find" button to replace 按“查找”按钮进行替换

then click Build-Rebuild to rebuild the project, and it could build successfully. 然后单击Build-Rebuild重建项目,它可以成功构建。

在此处输入图片说明

Or you can just use this forked library: link , he did that replace job for you. 或者,您可以只使用此派生库: link ,他为您完成了替换工作。

I got the same issue because I'm using the MaterialDesign Library in my android application where the rippleColor attribute is defined. 我遇到了同样的问题,因为我在定义了rippleColor属性的Android应用程序中使用了MaterialDesign库 Here is the example which shows how I've solved this issue. 这是显示我如何解决此问题的示例。

在此处输入图片说明

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 错误:(1)属性“ rippleColor”已在android studio中定义 - Error:(1) Attribute “rippleColor” has already been defined in android studio Android:属性'rippleColor'已经定义 - Android: Attribute 'rippleColor' has already been defined 属性“ rippleColor”已经定义 - Attribute ”rippleColor“ has already been defined Gradle错误“属性”xxx“已在Android Studio中定义” - Gradle error “Attribute ”xxx“ has already been defined” in Android Studio 解决Android Studio中Gradle错误“属性“ xxx”已定义”的有效方法? - Efficient way to fix Gradle error “Attribute ”xxx“ has already been defined” in Android Studio? 属性“titleTextStyle”已在android studio 1.2.1中定义? - Attribute “titleTextStyle” has already been defined in android studio 1.2.1? 错误:属性“ android:orientation”已经定义 - Error:Attribute “android:orientation” has already been defined Android:错误:(464)属性“ dividerPadding”已经定义 - Android: Error:(464) Attribute “dividerPadding” has already been defined Android属性已经定义 - Android Attribute has already been defined 错误:属性“主题”已定义 - Error:Attribute “theme” has already been defined
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM