0

When I try to compile an android project in Intellij IDEA I get

Unable to execute DX
com.android.dex.DexIndexOverflowException: method ID not in [0, 0xffff]: 65536
at com.android.dx.merge.DexMerger$6.updateIndex(DexMerger.java:484)
at com.android.dx.merge.DexMerger$IdMerger.mergeSorted(DexMerger.java:261)
at com.android.dx.merge.DexMerger.mergeMethodIds(DexMerger.java:473)

Searching I have found these solutions

A) add

android {
    dexOptions {
        jumboMode = true
    }
}

in buid.gradle

or

B) add

dex.force.jumbo=true

in project.proprerties for non-gradle projects

I haven't any build.gradle so I have tried the second solution adding the line at the end of project.properties in this way

# Project target.

target=Google Inc.:Google APIs:23
dex.force.jumbo=true

Unfortunately this solution doesn't work and get the same error. My classes aren't too much big and want to avoid Multidex... with my surprise this error happens only after the update of the Android support v4 library and Google Play Services to latest release.

Any suggestion?

AndreaF
  • 11,975
  • 27
  • 102
  • 168
  • See: http://stackoverflow.com/questions/26571728/what-does-string-count-mean-in-dex-file-android – Morrison Chang Mar 04 '16 at 22:35
  • @MorrisonChang Yet seen before ask the question and doesn't solve my problem. – AndreaF Mar 04 '16 at 22:37
  • And you are only using the Google Play Services you need rather than importing the full set? – Morrison Chang Mar 04 '16 at 22:43
  • I'm not sure what parts of Google Play Services I need, and I don't know how to compile only the components needed without errors. In any case I need to know how to solve the issue of force jumbo mode – AndreaF Mar 04 '16 at 23:00
  • In my opinion force jumbo mode isn't going to solve your problem as it deals with strings and your error looks like method count. Since you mention that the error only started when you upgraded Google Play Services see: https://developers.google.com/android/guides/setup#split – Morrison Chang Mar 04 '16 at 23:13
  • @MorrisonChang In your link there are the istructions for gradle. I don't have any build.gradle file. How do I have to deal with project.properties and selective compilation? – AndreaF Mar 04 '16 at 23:22
  • You mentioned IntelliJ, load up Android Studio and migrate your project to gradle, everything new is going there and its what Google is supporting. – Morrison Chang Mar 04 '16 at 23:30
  • 1
    Gradle support still sucks, I don't want to waste time to recreate all my projects if there is another way to fix the issue. I have used gradle in past years and every new release forced me to create a new project to fix framework detection issue and compilations errors. – AndreaF Mar 04 '16 at 23:39

1 Answers1

2

The dex format does not support method indices over 64k.

Jumbo mode is useful in cases when your dex file has many strings (>64k), and you need to merge in other dex files (libraries, etc.). It basically forces the bytecode to always use jumbo string references to avoid issues when merging the dex files.

Notably, jumbo mode has nothing to do with method indexes, and doesn't help when you have too many methods.

JesusFreke
  • 19,784
  • 5
  • 65
  • 68
  • Are you sure? the answers that suggested jumbo mode are pretty new. I think is the way I add the parameter the problem. – AndreaF Mar 04 '16 at 22:13
  • https://android.googlesource.com/platform/dalvik/+/f870f2dce9300c8dec620613371f08e5c234245b - looks like it was added in 2012 :) – JesusFreke Mar 05 '16 at 00:03