面对 Dex 65K 方法限制错误

Facing Dex 65K methods limitation error

我的应用程序出现此错误:

java.lang.IllegalArgumentException: method ID not in [0, 0xffff]: 65536

我知道这是由于单个 dex 文件中的 65K 方法限制。所以,我把 multiDexEnable true 放在我的 build.gradle 中。但是现在,我得到了另一个错误:

Execution failed for task ':app:transformClassesWithMultidexlistForSitraRelease'.

java.io.IOException: Can't read [C:\Program Files\adt-bundle-windows\build-tools.0.0\multidex\shrinkedAndroid.jar] (No such file or directory)

我能做什么?

编辑

我添加了 com.android.support:multidex:1.0.0 依赖项并将 App extends Application 更改为 App extends MultiDexApplication 但仍然无法正常工作。

注意:当我删除依赖项时 com.batch.android:batch-sdk:1.5+ 一切正常。

您必须从 MultidexApplication 扩展 Application class。 此外,您需要将 gradle.build 文件添加到 compile 'com.android.support:multidex:1.0.0'.

尝试将 compile "com.android.support:multidex:1.0.1" 添加到 build.gradle 中的依赖项中。我相信您需要这个以及 multiDexEnabled true.

在您的 build.gradle 文件中,将 buildToolsVersion 更新为 21.1.0 或更高版本。 (您目前使用的是 20.0.0)

类似于:

android {
    compileSdkVersion 21
    buildToolsVersion "21.1.0"
...

并确保您的 sdk 管理器是最新的。

更多信息:http://developer.android.com/intl/es/tools/building/multidex.html#mdex-gradle