【问题标题】:Why Android Gradle preDexDebug "Source and destination must be different" build failed?为什么Android Gradle preDexDebug“源和目标必须不同”构建失败?
【发布时间】:2014-09-13 05:30:21
【问题描述】:

我有一个使用 Android Studio 0.8.1 构建的 Android 应用程序并遇到问题:

Error:Execution failed for task ':app:preDexDebug'.
> java.lang.IllegalArgumentException: Source C:\Users\mfedorov\AndroidStudioProjects\EPOS2\app\build\intermediates\pre-dexed\debug\mate-api-0.0.1-SNAPSHOT-0ef7e3259aeaf19202f545da97dc6b1ae2502c9a.jar and destination C:\Users\mfedorov.ALTIUS-PLUS\AndroidStudioProjects\EPOS2\app\build\intermediates\pre-dexed\debug\mate-api-0.0.1-SNAPSHOT-0ef7e3259aeaf19202f545da97dc6b1ae2502c9a.jar must be different

这是我的build.gradle文件内容(我改过的部分,其余部分默认)

configurations.all {
    // check for updates every build
    resolutionStrategy.cacheChangingModulesFor 0, 'seconds'
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])

    compile 'org.apache.commons:commons-collections4:4.0'
    compile 'org.slf4j:slf4j-android:1.7.7'
    compile 'com.altius.logging:logging-utils:0.0.1-SNAPSHOT'
    compile group: "com.altius.mate", name: "mate-bluetooth", version: "0.0.1-SNAPSHOT", changing: true
    compile group: "com.altius.mate", name: "mate-api", version: "0.0.1-SNAPSHOT", changing: true
    //compile('org.simpleframework:simple-xml:2.7.1') {
    //exclude group: 'stax', module: 'stax-api'
    //exclude group: 'xpp3', module: 'xpp3'
    //}

}

根 build.gradle 的内容默认是使用 android 项目创建的

mate-api-0.0.1-SNAPSHOT 工件来自 Maven 本地存储库 mavenLocal()

【问题讨论】:

  • 您是否尝试过清理项目?
  • 转到 Build -> Clean Project 问题就解决了。

标签: android gradle android-studio android-gradle-plugin


【解决方案1】:

删除你项目中的build文件夹并使android studio中的缓存失效,重启android studio

【讨论】:

    【解决方案2】:

    答案只是清理项目。我有一段时间遇到同样的问题。

    构建 -> 清理项目

    【讨论】:

    • 这对我没有用,我还必须手动删除所有 /build 文件夹。
    • 我必须从 IntelliJ IDEA 中的 Gradle 工具窗口运行清理命令。构建 -> 清理项目不起作用。
    • 在我的情况下没有帮助:/ 必须删除对 hamcrest-all.jar(由 LambdaJ 使用)的依赖:code.google.com/p/hamcrest/issues/detail?id=145
    • 发生在我身上的“gradle clean build” - 所以 clean 并没有真正帮助 - 似乎是一个错误。有趣的是,第二个“gradle clean build”进展顺利..
    • 这对我来说非常适合 Android Studio 2.1.2 Build #AI_143.2915827。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-06-13
    • 1970-01-01
    • 2016-02-04
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多