0

For my project method count is 55K. Clearly less than 65k limit. When I try to run app in eclipse/studio I am getting

Conversion to Dalvik format failed: Unable to execute dex: field ID not in [0, 0xffff]: 65536

I have 5-6 libraries included in project also my app has many features.

On Google I found many links for Conversion to Dalvik format failed: Unable to execute dex: method ID not in [0, 0xffff]: 65536 with possible solution of multidex configuration.

But how to Fix >>> field ID not in [0, 0xffff]: 65536 ????

R World
  • 766
  • 9
  • 26
  • `For my project method count is 55K.` where is your proof? Do not use `Eclipse`, use `AS` or `Intellij`. Can you post your `build.gradles`? – Jared Burrows Jul 24 '15 at 20:25
  • 1
    The solution should be similar to having too many method ids. You need to reduce the number of fields (remove dependencies?), use proguard, or use multi-dex. – JesusFreke Jul 24 '15 at 22:05

1 Answers1

0

You mention that your method count is 55K, which is indeed less than the 65K limit imposed by the dex format.

The error that you're seeing isn't related to the number of methods, however. Dex also limits you to 65K fields, i.e. instance variables. You seem to be hitting that limit. To fix it, you'll have to examine what in your app (and the libraries it uses) has so many fields.

I wrote a gradle plugin that will give you this info on every build. It's on github at https://github.com/KeepSafe/dexcount-gradle-plugin.

Ben
  • 6,023
  • 1
  • 25
  • 40
  • Can you define meaning of **execute dex: field ID**. What is included in this image resources/all the variables in strings.xml? anything is accessible with R.id.* or all the instance variables in my classes? Or both? – R World Jul 31 '15 at 22:12
  • Dex stores fields in a single array, and references them with a two-byte number. The largest two-byte number is 65536. Hence, if you have more fields than that, the format is not capable of assigning a unique ID to all of them. All fields, whether yours, from a library, or generated (including `R.*`), count towards this limit. – Ben Jul 31 '15 at 22:23
  • Also, `Unable to execute dex` literally means that the invocation of the `dex` utility failed. `field ID not in [0, 0xFFFF]` is the specific error message. Also, I mis-spoke above - the largest two-byte number is 65535, not 65536. Off-by-one errors, you know! – Ben Jul 31 '15 at 22:28