相关疑难解决方法(0)

DexIndexOverflowException:无法将新索引65772合并为非巨型指令!:Jumbo Mode?和/或Multi-Dex?幕后的是什么?

我试图在gradle中为我的项目设置jumboMode,它似乎能够解决以下DexIndexOverflowException:

com.android.dex.DexException:无法将新索引65536合并为非巨型指令!

DexIndexOverflowException:无法将新索引65772合并为非jumbo指令!

1)什么是jumboMode选项实际上在幕后做了什么?

android {
    ...
    dexOptions {
        jumboMode true
    }

}
Run Code Online (Sandbox Code Playgroud)

2)我也注意到启用multi-dex也可以解决同样的问题,这两种方法之间的正确选择是什么?

android {
    ...
    defaultConfig {
        ...
        multiDexEnabled true
    }
}
Run Code Online (Sandbox Code Playgroud)

android mode dex android-multidex

18
推荐指数
1
解决办法
1万
查看次数

Android Studio 3.0上的com.android.dex.DexIndexOverflowException

我有一个用于Espresso测试的库,当我添加到我的项目时,我无法编译我的测试.

Gradle输出此错误

Caused by: com.android.dex.DexIndexOverflowException: method ID not in [0, 0xffff]: 65536
    at com.android.dx.merge.DexMerger$8.updateIndex(DexMerger.java:565)
    at com.android.dx.merge.DexMerger$IdMerger.mergeSorted(DexMerger.java:276)
    at com.android.dx.merge.DexMerger.mergeMethodIds(DexMerger.java:574)
    at com.android.dx.merge.DexMerger.mergeDexes(DexMerger.java:166)
    at com.android.dx.merge.DexMerger.merge(DexMerger.java:198)
Run Code Online (Sandbox Code Playgroud)

这真的很奇怪,因为我已经在我的项目中启用了multiDex

我的项目build.gradle

defaultConfig {
            minSdkVersion 16
            targetSdkVersion 21
            versionName versionNameFromGitTagVia()
            versionCode versionCodeFromJenkins()
            multiDexEnabled true

            testInstrumentationRunner "app.test.general.InstrumentationRunner" ...
}
dependencies {
    ...
    androidTestImplementation project(':test-utils')
    ...
    implementation 'com.android.support:multidex:1.0.2'
}
Run Code Online (Sandbox Code Playgroud)

我的应用类

public class RiderApplication extends MultiDexApplication implements Application.ActivityLifecycleCallbacks,
        GoogleApiClient.ConnectionCallbacks, GoogleApiClient.OnConnectionFailedListener {
  ....
}
Run Code Online (Sandbox Code Playgroud)

AndroidManifest

<application
    android:name=".RiderApplication"
    android:allowBackup="true"
    android:icon="@mipmap/ic_launcher"
    android:label="@string/app_name"
    android:largeHeap="true"
    android:theme="@style/MyAppTheme"
    tools:replace="android:theme,android:icon">
Run Code Online (Sandbox Code Playgroud)

删除库可以解决问题

有什么建议?

编辑 我尝试用几种方法解决它,我发现只有当我将库包含在内时才会发生这种情况

androidTestImplementation
Run Code Online (Sandbox Code Playgroud)

但是当作为常规使用时

implementation
Run Code Online (Sandbox Code Playgroud)

dex错误消失了

真奇怪 …

android android-multidex

11
推荐指数
1
解决办法
889
查看次数

标签 统计

android ×2

android-multidex ×2

dex ×1

mode ×1