Question

I just added Ormlite on my android project and I get the follow error:

Error:Execution failed for task ':AgCelence:dexDebug'.
    > com.android.ide.common.internal.LoggedErrorException: Failed to run command:
    /my/home/path/apps/Android/sdk/build-tools/19.0.3/dx --dex --output /my/home/path/workspace/my/project/path/build/dex/debug
    /my/home/path/workspace/my/project/path/build/classes/debug
    /my/home/path/workspace/my/project/path/build/dependency-cache/debug
    /my/home/path/workspace/my/project/path/build/pre-dexed/debug/butterknife-4.0.1-5a7b9ed780d5fa0603abb39fdc181c512fa9b1c3.jar
    /my/home/path/workspace/my/project/path/build/pre-dexed/debug/classes-1a1090f3a59a705e7e344c2ae25b0c5f88f721d6.jar
    /my/home/path/workspace/my/project/path/build/pre-dexed/debug/classes-edaf04f87f77ab0f4105648ab63bdcd09694eb0d.jar
    /my/home/path/workspace/my/project/path/build/pre-dexed/debug/dagger-1.2.1-212943657b662e900a542e2d88abbd5fdcaf8d33.jar
    /my/home/path/workspace/my/project/path/build/pre-dexed/debug/flurry-3.4.0-6b0fea36afcc1a3b450e16a58c03d9869b754f02.jar
    /my/home/path/workspace/my/project/path/build/pre-dexed/debug/gson-2.2.4-3d9d795bb76d7955fd85ce17556cc505830bd1f7.jar
    /my/home/path/workspace/my/project/path/build/pre-dexed/debug/javax.inject-1-e8f1138f6c9c0f8271805129c6151ff544950b34.jar
    /my/home/path/workspace/my/project/path/build/pre-dexed/debug/ormlite-android-4.9-5eaa7600b65948820881b78781d30698f1033ff5.jar
    /my/home/path/workspace/my/project/path/build/pre-dexed/debug/ormlite-core-4.9-25352cf2f40621c7a86eff7f10a40c6a66cdf76a.jar
    /my/home/path/workspace/my/project/path/build/pre-dexed/debug/support-v4-19.1.0-8212ff791cfaeb109a87aa612d03eec280361949.jar
Error Code:
    2
Output:
    UNEXPECTED TOP-LEVEL EXCEPTION:
    com.android.dex.DexException: Multiple dex files define Lcom/j256/ormlite/dao/CloseableIterable;
        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)

my 'build.gradle':

apply plugin: 'android'

android {
    compileSdkVersion 19
    buildToolsVersion '19.0.3'
    defaultConfig {
        minSdkVersion 15
        targetSdkVersion 19
        versionCode 1
        versionName '0.1.0'
    }
    buildTypes {
        release {
            runProguard false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile project(':porquenaotoolkit')
    compile project(':libraries:twoway-view:TwoWayView')
    compile 'com.android.support:support-v4:19.+'
    compile 'com.squareup.dagger:dagger:1.2.+'
    compile 'com.jakewharton:butterknife:4.0.+'
    compile 'com.google.code.gson:gson:2.2.+'
    compile 'com.j256.ormlite:ormlite-android:4.9'
}

porquenaotoolkit build.gradle:

apply plugin: 'android-library'

android {
    compileSdkVersion 19
    buildToolsVersion "19.0.3"

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

dependencies {
    compile 'com.jakewharton:butterknife:4.0.+'
    compile 'com.google.code.gson:gson:2.2.+'
    compile fileTree(dir: 'libs', include: ['*.jar'])
}

TwoWayView build.gradle:

apply plugin: 'android-library'

repositories {
    mavenCentral()
}

dependencies {
    compile 'com.android.support:support-v4:18.0.+'
}

android {
    compileSdkVersion 16
    buildToolsVersion "19.0.0"
}

Anyone have any idea of how solve this issue??? If I remove the line compile 'com.j256.ormlite:ormlite-android:4.9' from my build.gradle the problem do not occurs, but I want use this library and I want use the gradle to manage this....

Was it helpful?

Solution

I solve my own problem changing the lines of my build.gradle from:

compile 'com.android.support:support-v4:19.+'
compile 'com.j256.ormlite:ormlite-android:4.9'

to:

compile 'com.android.support:support-v4:19.1.0'
compile 'com.j256.ormlite:ormlite-android:4.48'

and changing the lines of TwoWayView build.gradle from:

buildToolsVersion "19.0.0"
compile 'com.android.support:support-v4:18.0.+'

to:

buildToolsVersion "19.0.3"
compile 'com.android.support:support-v4:19.1.0'

it seens be a problem of differents support library jars files... It's a pity the Android Studio do not solve mutiple dex files problem... I see a lot of problems of this type.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top