MarshallLee MarshallLee - 3 months ago 23x
Android Question

Android: Attribute 'rippleColor' has already been defined

My Android application had no problems with this build.gradle file.

apply plugin: ''
apply plugin: ''

android {
compileSdkVersion 23
buildToolsVersion "23.0.1"

defaultConfig {
applicationId "com.marshall.opensurvey"
minSdkVersion 15
targetSdkVersion 23
versionCode 1
versionName "1.0"
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), ''

repositories {

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile ''
compile ''
compile ''
compile ''
compile ''
compile 'com.squareup.okhttp:okhttp:2.0.0'

// Material Drawer Library by Mike Penz
compile('com.mikepenz:materialdrawer:4.3.9@aar') {
transitive = true
// Android Iconics Library by Mike Penz
compile 'com.mikepenz:iconics-core:1.7.9@aar'
compile 'com.mikepenz:google-material-typeface:'
// Google Analytics Library
compile ''
// Circle Image View Library
compile 'de.hdodenhof:circleimageview:2.0.0'
// Flat Button Library
compile 'info.hoang8f:fbutton:1.0.5'
// Process Button Library
compile ''
// Fancy Button Library
compile 'com.github.medyo:fancybuttons:1.5@aar'

// Card View and Recycler View Library
compile ''
compile ''

But, as I added another dependency in the build.gradle file and synced, it started to show an error, saying that the attribute 'rippleColor' has already been defined. The new dependency I put in the gradle file is this.

// Material Design Library
compile 'com.github.navasmdc:MaterialDesign:1.5@aar'

I assume that this error is shown because the newly added one contains an attribute which has the same name that is already defined in the previously added libraries. What should I modify in this file so that the third-party libraries do not crash each other?


The problem is that the MaterialDesign library does not prefix its attributes.

The attributes are defined in the attrs.xml and you will have to rename the rippleColor attribute to something else. A good advice here is to prefix all attributes specific to this library, so those won't conflict with other libs.

So it will look like this

<?xml version="1.0" encoding="utf-8"?>
    <declare-styleable name="CustomAttributes">
        <!-- Color of ripple animation -->
        <attr name="mdl_rippleColor" format="color|reference" />
        <!-- You can also prefix all other attributes -->

Afterwards you will have to find all occurrences of this in the code of the MaterialDesign Library and prefix them too so those attributes can be read programmatically. One is in the LayoutRipple (Line: 56) class.

It also seems as this library isn't actively maintained anymore. Circa 200 open issues, and 30 pull requests.

To simplify everything for you i've modified and fixed the source (i have also updated to the latest v23.1.0 support library) and uploaded it to the SNAPSHOT maven central repository. You can use it by doing the following 2 steps:

Add the SNAPSHOT maven repository to your root build.gradle

maven { url "" }

As shown here: SNAPSHOT maven repository

Add the dependency to your build.gradle

compile 'com.mikepenz.thirdparty:material-design-library:1.5.0-SNAPSHOT'

Here's the link to the SNAPSHOT *.aar. The maven group is different as i am not allowed to host it with the original maven group.