[英]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 :
如果下载了该模块并将其添加为依赖项,则可以按以下方式解决此问题:
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.