【问题标题】:Import Spring Framework with Gradle 1.11 causes Multiple dex files define error使用 Gradle 1.11 导入 Spring Framework 导致多个 dex 文件定义错误
【发布时间】:2014-07-13 21:52:51
【问题描述】:

根据 Spring Framework Android quickstart,如果您使用 Gradle 构建项目,则应添加以下行作为构建依赖项:

dependencies {
    compile 'org.springframework.android:spring-android-rest-template:1.+'
    compile 'org.springframework.android:spring-android-auth:1.+'
    compile 'org.springframework.android:spring-android-core:1.+'
}

但是,Gradle 1.11 出现以下错误:

UNEXPECTED TOP-LEVEL EXCEPTION:
    com.android.dex.DexException: Multiple dex files define
            Lorg/springframework/core/ErrorCoded;
    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)

【问题讨论】:

    标签: android spring gradle


    【解决方案1】:

    根据 Spring.io 的this 线程,“用于 Android 的 Spring REST 模板和核心工件不依赖于 Spring 核心或任何 Spring Framework 库。但是,auth 依赖项确实如此与 Spring Social".

    因此,一种可能的解决方案是将这些重复的依赖项标记为排除:

    dependencies {
        compile('org.springframework.android:spring-android-auth:1.+') {
            exclude group :'org.springframework', module: 'commons-logging'
            exclude group :'org.springframework', module: 'spring-core'
            exclude group :'org.springframework', module: 'spring-web'
        }
        compile 'org.springframework.android:spring-android-core:1.+'
        compile 'org.springframework.android:spring-android-rest-template:1.+'
    }
    

    【讨论】:

    • Here 你可以找到许多使用 Gradle 0.9 和 Gradle 1.11 的 Spring Android 示例。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-07-12
    • 2014-11-17
    • 1970-01-01
    相关资源
    最近更新 更多