任务执行失败':app:transformClassesWithDexForDebug'在小应用程序中

时间:2016-12-30 13:41:15

标签: android gradle

我正在尝试构建一个Android项目(这是一个小项目),我在Travis中遇到了这个错误:

* What went wrong:
Execution failed for task ':app:transformClassesWithDexForDebug'.
> com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: java.util.concurrent.ExecutionException: com.android.dex.DexIndexOverflowException: method ID not in [0, 0xffff]: 65536

我知道我可以通过启用multiDex来解决这个问题,但是我不认为这个错误会发生在我的情况下,因为我不相信该项目及其依赖项超过了multiDex的方法限制

以下是build.gradle文件中的依赖项:

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    compile project(':geth')
    compile 'com.android.volley:volley:1.0.0'
    compile 'com.google.android.gms:play-services-maps:10.0.1'
    compile 'com.android.support:appcompat-v7:25.1.0'
    compile 'com.android.support:support-v4:25.1.0'
    compile 'com.android.support:design:25.1.0'
    testCompile 'junit:junit:4.12'
}

有什么想法吗?

由于

1 个答案:

答案 0 :(得分:3)

您超过了65536种方法。也许这个:geth项目太大了?

您可以打开多索引,更多信息:

https://developer.android.com/studio/build/multidex.html

您可以使用以下方法检查项目的哪个部分采用过多的方法索引:

https://github.com/KeepSafe/dexcount-gradle-plugin