gpt4 book ai didi

android - 关于构建错误 : DexIndexOverflowException

转载 作者:行者123 更新时间:2023-11-30 00:21:55 27 4
gpt4 key购买 nike

我们在构建应用程序代码时遇到构建错误 DexIndexOverflowException。

似乎我们应用程序中的某些代码或应用程序中包含的库正在调用 Google Play 服务中的函数,调用次数上限为 65536 次。

为了进一步追踪它,您能否告诉我们一种方法来深入了解可能导致上述错误的依赖项。

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

//compile files('libs/commons-collections-3.2.1.jar')
compile(name: 'HERE-sdk', ext: 'aar')
compile('com.crashlytics.sdk.android:crashlytics:2.6.8@aar') {
transitive = true;
}
compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.android.support:design:25.3.1'
compile 'com.android.support:support-v4:25.3.1'
compile 'com.android.support:recyclerview-v7:25.3.1'
compile 'com.google.android.gms:play-services-location:11.0.4'
compile 'com.bugfender.sdk:android:0.8.4'
compile 'com.google.code.gson:gson:2.2.4'
compile 'com.squareup.okhttp3:logging-interceptor:3.8.0'
compile 'com.squareup.retrofit2:retrofit:2.0.2'
compile 'com.squareup.retrofit2:converter-gson:2.0.2'
compile 'com.github.lzyzsd:circleprogress:1.2.1'
compile 'com.google.firebase:firebase-core:11.0.4'
compile 'com.google.firebase:firebase-auth:11.0.4'

}
apply plugin: 'com.google.gms.google-services'

最佳答案

这不是单个依赖项的问题,问题是因为所有依赖项的方法计数加上您的应用程序代码的方法计数加起来超过 65536

android docs 中所述

Both these error conditions display a common number: 65,536. This number is significant in that it represents the total number of references that can be invoked by the code within a single Dalvik Executable (DEX) bytecode file. This page explains how to move past this limitation by enabling an app configuration known as multidex, which allows your app to build and read multiple DEX files.

关于文档,如果不尝试在从构建文件中删除所有不必要的依赖项后构建项目,请确保使用在 gradle.build 文件中提到的所有依赖项。

如果你仍然有问题,那么你需要在代码上启用 multidex

如果你的 minSdkVersion 小于 21 那么你需要将它添加到构建 gradle

android {
defaultConfig {
...
minSdkVersion 21
targetSdkVersion 26
multiDexEnabled true
}
...}



dependencies {
compile 'com.android.support:multidex:1.0.1'
}

如果您使用的是单独的应用程序类(您可能是因为您使用的是 crasylitics),则改 rebase 础应用程序以扩展 MultiDexApplication。如果没有将以下内容添加到您的 list 文件中

            android:name="android.support.multidex.MultiDexApplication" >

然后尝试重新编译它。

荣誉

关于android - 关于构建错误 : DexIndexOverflowException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46134468/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com