duplicate library gradle animatorlistener duplicat

2019-08-06 04:19发布

问题:

I'm trying to use some libraries into my android project and I'm facing some problems with different libraries. I have a library which I import from maven repository that has "nineoldandroids" library dependency. After that I have another import that uses the same library and I did a exclude of that module. Now if I sync Gradle everything works fine but when I try to run my app I get the following error

"Error:Class com.nineoldandroids.animation.Animator.AnimatorListener has already been added to output. Please remove duplicate copies."

I think that both libraries are trying to use the same Listener and I get that error but I'm not able to solve it and I didn't find useful information for me. If somebody can help me I would appreciate it. This is my gradle file. BTW last library must be manually included and it's placed in my "libs" folder.

apply plugin: 'com.android.application'

android {
    compileSdkVersion 21
    buildToolsVersion "21.1.1"

    defaultConfig {
        applicationId "com.infortec.acostela.pescamerca"
        minSdkVersion 19
        targetSdkVersion 21
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    repositories{
        jcenter()
        flatDir {
           dirs 'libs'
        }
    }
    dexOptions {
        preDexLibraries = false
    }
}

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    compile 'com.android.support:appcompat-v7:21.0.+'
    compile "com.android.support:gridlayout-v7:18.0.+"
    compile 'com.j256.ormlite:ormlite-core:4.48'
    compile 'com.j256.ormlite:ormlite-android:4.48'
    compile 'commons-net:commons-net:3.3'
    compile 'net.sf.opencsv:opencsv:2.3'
    compile 'com.rengwuxian.materialedittext:library:1.8.2'
    compile ('libs.example:material:0.4.3@aar'){
        exclude module: 'nineoldandroids'
    }
 }

回答1:

Finally I solved it.

The problem was that I must exclude the whole library, not only the module so writing the following solved it.

compile ('com.rengwuxian.materialedittext:library:1.8.2'){
    exclude group: 'com.nineoldandroids', module: 'library'
}