1

We are getting build error DexIndexOverflowException while building our app code.

Seems some of our code in app or included libs in app is calling functions in Google Play service upto limit of 65536 calls.

To trace it further can you tell us a way to drill down to the dependencies which might be responsible for above error.

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' 

1 Answer 1

1

It is not an issue with a single dependency, The issue is because all the dependency's method count plus your application code's method count add up to more than 65536

As Mentioned in the 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.

With regard to the doc make sure you use all the dependencies that you have mentioned on the gradle.build file if not try building the project after removing all unnecessary dependencies from the build file.

If Still You have the issue, Then you need to enable multidex on the code

If Your minSdkVersion is less than 21 then you need add this to the build gradle

android { defaultConfig { ... minSdkVersion 21 targetSdkVersion 26 multiDexEnabled true } ...} dependencies { compile 'com.android.support:multidex:1.0.1' } 

and alter the base Application to extend MultiDexApplication in either if you are using a separate application class (you might cos you are using crasylitics). If not add the following to your Manifest File

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

And then try recompiling it.

kudos

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks for your answer.. Yes we enabled multidex in app and also we are debugging code also to see if we can remove some libs..

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.