0

I have two libraries on my proyect.

https://github.com/rengwuxian/MaterialEditText

https://github.com/navasmdc/MaterialDesignLibrary

It compiles, but when I run the program it reports an error.

UNEXPECTED TOP-LEVEL EXCEPTION:
Error:Execution failed for task ':app:dexDebug'.
> com.android.ide.common.internal.LoggedErrorException: Failed to run command:
    C:\Users\Alvaro\AppData\Local\Android\sdk\build-tools\21.1.2\dx.bat --dex --no-optimize --output D:\ALVARO\AndroidStudioProjects\Proyecto\app\build\intermediates\dex\debug --input-list=D:\Alva\AndroidStudioProjects\Proyecto\app\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 KNOW THE PROBLEM, BUT I CAN'T SOLVE

Problem

Multiple dependencies are trying to import nineoldandroids exactly "nineoldandroids"

app build.gradle

apply plugin: 'com.android.application'

android {
    compileSdkVersion 21
    buildToolsVersion "21.1.2"

    defaultConfig {
        applicationId "com.example.alva.proyecto"
        minSdkVersion 14
        targetSdkVersion 21
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt')
        }
    }
}

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    compile 'com.android.support:appcompat-v7:21.0.3'

    //seconds library
    compile project(':materialDesign')

    //first library
    compile project(':EditText') 
}

first library build.gradle

apply plugin: 'com.android.library'

android {
    compileSdkVersion 21
    buildToolsVersion "21.1.2"

    defaultConfig {
        minSdkVersion 14
        targetSdkVersion 21
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile 'com.android.support:support-annotations:21.0.3'
    compile 'com.nineoldandroids:library:2.4.0'
    compile 'com.android.support:appcompat-v7:21.0.3'
}

seconds library build.gradle

apply plugin: 'com.android.library'

android {
    compileSdkVersion 8
    buildToolsVersion "19.1.0"

    defaultConfig {
        minSdkVersion 8
        targetSdkVersion 8
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
        }
    }
}

dependencies {
    compile 'com.android.support:support-v4:18.+'
    compile files('libs/nineoldandroids-2.4.0.jar')
}

I have tried:

1. Put on "app" build.gradle:

compile project(':EditText') {

        exclude group: 'com.nineoldandroids', module: 'library:2.4.0'
    }

NOT WORKS, IT'S REPORTS AN ERROR

Error:(31, 0) Gradle DSL method not found: 'exclude()'
Possible causes:<ul><li>The project 'Proyecto' may be using a version of Gradle that does not contain the method.
<a href="openGradleSettings">Gradle settings</a></li><li>The build file may be missing a Gradle plugin.
<a href="apply.gradle.plugin">Apply Gradle plugin</a></li>

2. Remove "nineoldandroids" from seconds library, NOT WORKS

Any suggestions?

Aspicas
  • 4,498
  • 4
  • 30
  • 53
  • Why are you using these libraries locally, instead of using their respective artifacts? Then Gradle may be able to resolve your dependency conflict automatically. Beyond that, we cannot help you if all you do is shout "**NOT WORKS**" without explaining completely and precisely what you mean. For example, in the one case, you also shout "**IT'S REPORTS AN ERROR**" without actually providing us the error. – CommonsWare Feb 09 '15 at 23:31
  • @CommonsWare Sorry but.. you can read errors on my question, I copied too... and I don't know how to import using their respective artifacts... – Aspicas Feb 09 '15 at 23:34
  • "you can read errors on my question, I copied too" -- you are correct, for the first one. I apologize for not paying close enough attention. – CommonsWare Feb 09 '15 at 23:36
  • @CommonsWare don't worry, for the second error simply it's reports errors on library classes....I don't know how I can solve that issue... – Aspicas Feb 09 '15 at 23:39
  • BTW, with respect to the first error, you might look at http://gradle.1045684.n5.nabble.com/Excluding-a-transitive-dependency-from-a-project-td3344855.html – CommonsWare Feb 09 '15 at 23:42

1 Answers1

2

I don't know how to import using their respective artifacts

It is in the documentation for each library.

The MaterialEditText "Download" section cites:

compile 'com.rengwuxian.materialedittext:library:1.8.2'

The "How to Use" section of MaterialDesignLibrary cites:

repositories {
    jcenter()
}

dependencies {
    compile 'com.github.navasmdc:MaterialDesign:1.+@aar'
}

Then, Gradle will (hopefully) be able to detect that both of these dependencies themselves depend upon nineoldandroids and resolve the conflict. I say "hopefully" because whichever library the "seconds library build.gradle" comes from uses a local copy of nineoldandroids, which is not a good idea. Neither GitHub repo seems to have that particular build.gradle file, though, so you may be OK.

CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491
  • Okay, thanks, I'll do for next projects because I can't in this proyect, sure the reason seconds library comes from uses a local copy of nineildandroids... many thanks for your help. – Aspicas Feb 09 '15 at 23:54
  • @CommonsWare: would be honored if you could kindly take a look at my [question](http://stackoverflow.com/q/30979355/3287204) ... than you :) – Yash Sampat Jun 22 '15 at 12:52