0

I'm trying to add the library https://github.com/nhaarman/ListViewAnimations to my android project but I can't get it to work. Syncing gradle works just fine but when compiling I get the following error:

.
.
.
:AoEu:generateDebugSources UP-TO-DATE
:AoEu:compileDebugJava UP-TO-DATE
:AoEu:preDexDebug UP-TO-DATE
:AoEu:dexDebug
UNEXPECTED TOP-LEVEL EXCEPTION:
Error:Execution failed for task ':AoEu:dexDebug'.
> com.android.ide.common.internal.LoggedErrorException: Failed to run command:
    /Applications/Android Studio.app/sdk/build-tools/android-4.4W/dx --dex --num-threads=4 --output /Users/daniel/Documents/code/aoeu/Android_2/AoEu/build/intermediates/dex/debug /Users/daniel/Documents/code/aoeu/Android_2/AoEu/build/intermediates/classes/debug /Users/daniel/Documents/code/aoeu/Android_2/AoEu/build/intermediates/dependency-cache/debug /Users/daniel/Documents/code/aoeu/Android_2/AoEu/build/intermediates/pre-dexed/debug/acra-4.3.0-b1a053ff2be3ad0658e7414c9efb8db525d279e1.jar /Users/daniel/Documents/code/aoeu/Android_2/AoEu/build/intermediates/pre-dexed/debug/android-async-http-1.4.4-5a7d308e504ef524369d10df7ad6b18d2333a474.jar /Users/daniel/Documents/code/aoeu/Android_2/AoEu/build/intermediates/pre-dexed/debug/annotations-12.0-f2c0a1768643eb7fbcddd7f90bd7fdcf4b535025.jar /Users/daniel/Documents/code/aoeu/Android_2/AoEu/build/intermediates/pre-dexed/debug/classes-0f154ba1813ed5f2748c80e42224f29d69f31319.jar /Users/daniel/Documents/code/aoeu/Android_2/AoEu/build/intermediates/pre-dexed/debug/classes-2ab91006f92af352b41fd4a9cf08b90ebc384663.jar /Users/daniel/Documents/code/aoeu/Android_2/AoEu/build/intermediates/pre-dexed/debug/classes-308ca14b92a9fbc70b6a0c8040e145491fe009db.jar /Users/daniel/Documents/code/aoeu/Android_2/AoEu/build/intermediates/pre-dexed/debug/classes-30ff1a32817de610075def282e38c869b04a28dc.jar /Users/daniel/Documents/code/aoeu/Android_2/AoEu/build/intermediates/pre-dexed/debug/classes-367f4c8350acbcca39b062f9298b4706d303d64e.jar /Users/daniel/Documents/code/aoeu/Android_2/AoEu/build/intermediates/pre-dexed/debug/classes-51e92b8a83db801d712dc0a6700756d222ff3d7c.jar /Users/daniel/Documents/code/aoeu/Android_2/AoEu/build/intermediates/pre-dexed/debug/classes-954a78d07e1cba7e60b32fc998618db2b73536e5.jar /Users/daniel/Documents/code/aoeu/Android_2/AoEu/build/intermediates/pre-dexed/debug/classes-95ba17748132eea2f6b9fe72f64146a711039a2e.jar /Users/daniel/Documents/code/aoeu/Android_2/AoEu/build/intermediates/pre-dexed/debug/classes-98f64520cfb53411ed06a971922b9136a7f886db.jar /Users/daniel/Documents/code/aoeu/Android_2/AoEu/build/intermediates/pre-dexed/debug/classes-9ad84293ee46c4d1204f00c5a365ece1f451993d.jar /Users/daniel/Documents/code/aoeu/Android_2/AoEu/build/intermediates/pre-dexed/debug/classes-9f06efdb2c5340fb2b4c90881246b07488331f61.jar /Users/daniel/Documents/code/aoeu/Android_2/AoEu/build/intermediates/pre-dexed/debug/classes-ac9167c19813fd3034915e682cabd31010f5aea8.jar /Users/daniel/Documents/code/aoeu/Android_2/AoEu/build/intermediates/pre-dexed/debug/classes-accd233c53f9d41450f400d9af655aba4e024959.jar /Users/daniel/Documents/code/aoeu/Android_2/AoEu/build/intermediates/pre-dexed/debug/classes-b366d899959a2cce72d0209dc8cd82ba6acfc51c.jar /Users/daniel/Documents/code/aoeu/Android_2/AoEu/build/intermediates/pre-dexed/debug/classes-bd9b360242c9c5d28979cc9db28b5b6d13d5adf9.jar /Users/daniel/Documents/code/aoeu/Android_2/AoEu/build/intermediates/pre-dexed/debug/classes-beb603821493ae18d2e211c4ebc15c24d939288f.jar /Users/daniel/Documents/code/aoeu/Android_2/AoEu/build/intermediates/pre-dexed/debug/classes-c3e39f4f328039d2cfa6a50202a0dd905bb28947.jar /Users/daniel/Documents/code/aoeu/Android_2/AoEu/build/intermediates/pre-dexed/debug/classes-c432d4669d088a374e8c2f646918795e6afd502e.jar /Users/daniel/Documents/code/aoeu/Android_2/AoEu/build/intermediates/pre-dexed/debug/classes-e40aab9c8425cb5480d94955ff39b94eba0673fe.jar /Users/daniel/Documents/code/aoeu/Android_2/AoEu/build/intermediates/pre-dexed/debug/classes-e5cf02936df1867bef02bb7eba9cf7e782f8f580.jar /Users/daniel/Documents/code/aoeu/Android_2/AoEu/build/intermediates/pre-dexed/debug/classes-e6d28e65693575cc752648484d16f78af3e72109.jar /Users/daniel/Documents/code/aoeu/Android_2/AoEu/build/intermediates/pre-dexed/debug/classes-ed9e48e9155c614bf3fa9c35be086555a10775ac.jar /Users/daniel/Documents/code/aoeu/Android_2/AoEu/build/intermediates/pre-dexed/debug/commons-io-1.3.2-5123b7dd8aac03253c765cf8fdc5e64bd1d87e62.jar /Users/daniel/Documents/code/aoeu/Android_2/AoEu/build/intermediates/pre-dexed/debug/commons-lang3-3.3.2-2c464519455a1eb9cdda46245fc20ffc1add2f52.jar /Users/daniel/Documents/code/aoeu/Android_2/AoEu/build/intermediates/pre-dexed/debug/disklrucache-2.0.2-a9c89aae05bf7016b5926b3c62ece24b06cfd098.jar /Users/daniel/Documents/code/aoeu/Android_2/AoEu/build/intermediates/pre-dexed/debug/internal_impl-20.0.0-b6e3d4dce38e3b09e28016e8db8e4ae1bb763024.jar /Users/daniel/Documents/code/aoeu/Android_2/AoEu/build/intermediates/pre-dexed/debug/lib-core-3.0.0-70b1696546add9933c9d0ae0be680ebb68143b3e.jar /Users/daniel/Documents/code/aoeu/Android_2/AoEu/build/intermediates/pre-dexed/debug/library-2.4.0-8bb96134963e47cabbae008ca69e322b1f133527.jar /Users/daniel/Documents/code/aoeu/Android_2/AoEu/build/intermediates/pre-dexed/debug/okhttp-1.6.0-0cf0746018b0646a0e162fd0629520e2fbb998d1.jar /Users/daniel/Documents/code/aoeu/Android_2/AoEu/build/intermediates/pre-dexed/debug/okhttp-urlconnection-1.6.0-d1ddb162604ccb14c556bd8d52c46ce1abd8f372.jar /Users/daniel/Documents/code/aoeu/Android_2/AoEu/build/intermediates/pre-dexed/debug/support-annotations-21.0.0-rc1-9da56907a54bc62b80b021d0066dc3e5625c73ba.jar /Users/daniel/Documents/code/aoeu/Android_2/AoEu/build/intermediates/pre-dexed/debug/universal-image-loader-1.9.1-c662c9896a82f0f3822fee3cb4d5ab8000983974.jar
  Error Code:
    2
  Output:
    UNEXPECTED TOP-LEVEL EXCEPTION:
    com.android.dex.DexException: Multiple dex files define Lcom/nhaarman/listviewanimations/BaseAdapterDecorator;
        at com.android.dx.merge.DexMerger.readSortableTypes(DexMerger.java:594)
        at com.android.dx.merge.DexMerger.getSortedTypes(DexMerger.java:552)
        at com.android.dx.merge.DexMerger.mergeClassDefs(DexMerger.java:533)
        at com.android.dx.merge.DexMerger.mergeDexes(DexMerger.java:170)
        at com.android.dx.merge.DexMerger.merge(DexMerger.java:188)
        at com.android.dx.command.dexer.Main.mergeLibraryDexBuffers(Main.java:439)
        at com.android.dx.command.dexer.Main.runMonoDex(Main.java:287)
        at com.android.dx.command.dexer.Main.run(Main.java:230)
        at com.android.dx.command.dexer.Main.main(Main.java:199)
        at com.android.dx.command.Main.main(Main.java:103)
Information:BUILD FAILED
Information:Total time: 24.587 secs
Information:1 error
Information:0 warnings
Information:See complete output in console

I have tried both the 3.0 release of the library and 2.6.0 both maven and .jar and still the same error. Also tried cleaning and rebuilding the project. Anyone got any suggestions on what might be wrong and how to fix it?

My build.gradle

buildscript {
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:0.12.+'
     }
}
apply plugin: 'com.android.application'

repositories {
    mavenCentral()
    maven {
        name 'maven.aviary.com'
        url uri("http://maven.aviary.com/repo/release")
    }
}

android {
    compileSdkVersion 20
    buildToolsVersion '20'

    defaultConfig {
        minSdkVersion 14
        targetSdkVersion 20
    }

    packagingOptions {
        exclude 'META-INF/NOTICE.txt'
        exclude 'META-INF/LICENSE.txt'
    }

}

dependencies {
    compile 'com.github.chrisbanes.actionbarpulltorefresh:library:+'
    compile 'com.android.support:support-v4:20.+'
    compile 'com.google.android.gms:play-services:4.4.52'
    compile 'ch.acra:acra:4.3.0'
    compile 'com.nostra13.universalimageloader:universal-image-loader:1.9.1'
    compile 'com.loopj.android:android-async-http:1.4.4'
    compile 'com.github.johnkil.android-appmsg:appmsg:1.2.0'
    compile 'com.aviary.android.feather.sdk:aviary-sdk:3.4.3.351'
    compile 'com.nhaarman.listviewanimations:lib-core:3.0.+'
}

UPDATE - SOLVED Thanks! I used jarjar together with this article to solve the problem.

  • You have somehow included multiple copies of a JAR coming from the ListViewAnimations library. Some possible solutions which I have not tested myself: 1) http://stackoverflow.com/a/24768935/22904; 2) http://stackoverflow.com/a/22521673/22904. – Giulio Piancastelli Aug 17 '14 at 10:47

1 Answers1

1

I appears that the Aviary SDK includes parts listviewanimations.

I recommend you file a bug with Aviary.

Until they fix it, you can use jarjar to move the package com.nhaarman. to a different package.

References:

https://code.google.com/p/jarjar/

https://github.com/vRallev/jarjar-gradle

https://gist.github.com/mcholick/7177513

yogurtearl
  • 3,035
  • 18
  • 24
  • Thanks! I used jarjar together with this [article](http://priyanka-tyagi.blogspot.se/2013/03/dealing-with-java-hell-using-jarjar.html) to solve the problem. –  Aug 18 '14 at 19:12