1

I just created a new project in Android Studio and want to add the UserVoice Java SDK as a dependency.

I'm adding the line compile 'com.uservoice:uservoice-java:0.0.2' to the app build.gradle file in the dependencies block.

When I try to build it will fail the build with

Output:
    UNEXPECTED TOP-LEVEL EXCEPTION:
    com.android.dex.DexException: Multiple dex files define Lorg/apache/commons/collections/Buffer;
        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)

At this point I have not modified the project in any way. Is there any way to exclude the offending dependencies and getting the UserVoice SDK to work?

Thanks!

2 Answers2

2

The above didn't work for me, what was needed was to exclude the commons-collection dependency from uservoice.

compile('com.uservoice:uservoice-java:0.0.2'){
    exclude group: 'commons-collections'
}

This along with the following allowed it to play nice with gradle:

packagingOptions {
    exclude 'META-INF/LICENSE.txt'
    exclude 'META-INF/NOTICE.txt'
}
stealthcopter
  • 13,964
  • 13
  • 65
  • 83
0

I managed to get this working finally. What I did was add

dexOptions {
   preDexLibraries = false
}

to the build.gradle android block. This was suggested here

I had to also add

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

to the same block.

Community
  • 1
  • 1