AruLNadhaN AruLNadhaN - 6 months ago 24
Android Question

How to Remove Duplicate Libraries added via gradle?

I am using two libraries in my project. One is this and the other is this.

Whenever I run the App with Edit Test library it shows UNEXPECTED TOP-LEVEL EXCEPTION:

Error:Execution failed for task ':mobile:dexDebug'.
> com.android.ide.common.internal.LoggedErrorException: Failed to run command:
E:\Android\me\me\sdk\build-tools\21.1.2\dx.bat --dex --no-optimize --output C:\Project\RemoteiT\RemoteiT\mobile\build\intermediates\dex\debug --input-list=C:\Project\RemoteiT\RemoteiT\mobile\build\intermediates\tmp\dex\debug\inputList.txt
Error Code:
2
Output:
UNEXPECTED TOP-LEVEL EXCEPTION:
com.android.dex.DexException: Multiple dex files define Lcom/nineoldandroids/animation/Animator$AnimatorListener;
at com.android.dx.merge.DexMerger.readSortableTypes(DexMerger.java:596)
at com.android.dx.merge.DexMerger.getSortedTypes(DexMerger.java:554)
at com.android.dx.merge.DexMerger.mergeClassDefs(DexMerger.java:535)
at com.android.dx.merge.DexMerger.mergeDexes(DexMerger.java:171)
at com.android.dx.merge.DexMerger.merge(DexMerger.java:189)
at com.android.dx.command.dexer.Main.mergeLibraryDexBuffers(Main.java:454)
at com.android.dx.command.dexer.Main.runMonoDex(Main.java:303)
at com.android.dx.command.dexer.Main.run(Main.java:246)
at com.android.dx.command.dexer.Main.main(Main.java:215)
at com.android.dx.command.Main.main(Main.java:106)


I Assume that the above error shows that
com.nineoldandroids
is added twice or conflicting.

So I tried to remove it in the build.gradle file. But it is still showing the error!

Is my Assumption is right? Or elsewhere did I go wrong?

Build.gradle

apply plugin: 'com.android.application'

android {
compileSdkVersion 21
buildToolsVersion "21.1.2"

defaultConfig {
applicationId "me.aruhan.remt"
minSdkVersion 14
targetSdkVersion 21
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}

configurations {
// to avoid double inclusion of support libraries
all*.exclude group: 'com.nineoldandroids', module: 'materialDesign'
}

dependencies {
compile 'com.android.support:appcompat-v7:21.0.0'
compile project(':materialDesign')
compile 'com.rengwuxian.materialedittext:library:1.7.1'
}

Answer Source

Instead of adding it in the Configurations. I added the exclude for only the library like this:

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