Víctor Martín
Víctor Martín

Reputation: 3450

Conflict with android gradle project

since this morning I try to manage an error from gradle in android studio, but I couldn't solve it.

This is the error:

Gradle tasks [:app:assembleDebug]
UNEXPECTED TOP-LEVEL EXCEPTION:
1 error
0 warnings
Execution failed for task ':app:dexDebug'.
> com.android.ide.common.internal.LoggedErrorException: Failed to run command:
    C:\AndroidIDES\sdk\build-tools\19.0.1\dx.bat --dex --output C:\PMSL\Patovideos\app\build\dex\debug C:\PMSL\Patovideos\app\build\classes\debug C:\PMSL\Patovideos\app\build\dependency-cache\debug C:\PMSL\Patovideos\app\build\pre-dexed\debug\classes-d5d5a5f0ee3aa349db97373276cdf4ce1d756400.jar C:\PMSL\Patovideos\app\build\pre-dexed\debug\support-v4-19.0.1-4d62c5c6d8c8b8a26f02df44b7278821a9f5af4b.jar C:\PMSL\Patovideos\app\build\pre-dexed\debug\universal-image-loader-1.9.1-a1273e57a1a8b916291dfb13a6906d801ad6594f.jar C:\PMSL\Patovideos\app\build\pre-dexed\debug\universal-image-loader-1.9.1-javadoc-a86f634bf1d1005314ba37126bfafdad8f979c7c.jar C:\PMSL\Patovideos\app\build\pre-dexed\debug\universal-image-loader-1.9.1-sources-c2bc28216be226462ec688d3a3cc65fb947e01c5.jar C:\PMSL\Patovideos\app\build\pre-dexed\debug\universal-image-loader-1.9.1-with-sources-699e086d09eb3ee375070763bee8e42cdcacabc4.jar
Error Code:
    2
Output:
    UNEXPECTED TOP-LEVEL EXCEPTION:
    com.android.dex.DexException: Multiple dex files define Lcom/nostra13/universalimageloader/cache/disc/DiscCacheAware;
        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)

And this is the build.gradle

apply plugin: 'android'

android {
    compileSdkVersion 18
    buildToolsVersion '19.0.1'

    defaultConfig {
        minSdkVersion 10
        targetSdkVersion 19
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            runProguard false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
        }
    }
}

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

Where is the error?? Please help me... I'm tearing my hair

Upvotes: 1

Views: 2515

Answers (1)

Scott Barta
Scott Barta

Reputation: 80010

That error means that it's trying to include the class com.nostra13.universamimateloader.cache.disc.DiscCacheAware twice in your APK when it's building. I'm not sure where this class comes from; if it's something in your sources, make sure you don't have it in there twice somehow. If it's a library dependency, then you probably have two jars in your libs folder that include this class -- look through them and make sure you haven't doubled it up somewhere.

If you've been changing dependencies and libraries around, it's possible the build is in a bad state and doing a clean-and-rebuild will fix it. That perhaps isn't likely to be the problem, but it's a quick thing to try.

Upvotes: 1

Related Questions