Search code examples
android-studiogradleconflictnineoldandroids

Android Studio Conflicting Classes when using Library


I have just started using Android Studio, So forgive me if i am unable to explain the situation properly. But i will try to update details as required.

In my gradle project i use JakeWarton DiskCache with nineoldandroids Both as jar files added to the app/libs folder.

In addition there also a Library project from this location https://android-arsenal.com/details/1/122

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

dependencies {
    compile 'com.github.flavienlaurent:datetimepicker:0f5d399995'
}

I use it by adding the repository and dependency as shown above.

When i try to run this project i get following error

Execution failed for task ':app:packageAllDebugClassesForMultiDex'.

java.util.zip.ZipException: duplicate entry: com/nineoldandroids/animation/Animator$AnimatorListener.class

I can understand that since my app has a copy of nineoldandroids.jar and the lib-project also needs it at compile time there is some kind of issue.

How can i fix this conflict?


Solution

  • The library com.github.flavienlaurent:datetimepicker:0f5d399995 is using the nineoldandroids library as a maven dependency.

    dependencies {
        compile 'com.nineoldandroids:library:2.4.0'
        //...
    }
    

    Check the original build.gradle file in github.

    To solve your issue you have to:

    • remove the nineoldandroids.jar from your project
    • add the nineoldandroids library as maven dependency in your project

    Use:

    dependencies{
     //
     compile 'com.nineoldandroids:library:2.4.0'
    }