簡體   English   中英

使用Android Studio的Ormlite Multiple dex

[英]Ormlite Multiple dex with Android Studio

我剛剛在我的android項目中添加了Ormlite ,我得到了以下錯誤:

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)

我的'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"
}

任何人都知道如何解決這個問題??? 如果我從compile 'com.j256.ormlite:ormlite-android:4.9'刪除行compile 'com.j256.ormlite:ormlite-android:4.9' ,則問題不會發生,但我想使用這個庫,我想使用gradle來管理這個....

我解決了自己的問題,改變了我的build.gradle的行:

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

至:

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

並從以下位置更改TwoWayView build.gradle的行:

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

至:

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

它看起來是一個不同的支持庫jar文件的問題...很可惜Android Studio沒有解決多個dex文件問題...我看到很多這種類型的問題。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM