0

After implementing jumbo dex, we dont get any further dex errors. The ~65K string limit is now exceeded, but not the method count. What is the limits we now face, if any, for strings and methods in an Android app?

SamWise
  • 698
  • 10
  • 16

1 Answers1

3

After some exhaustive testing. The details can be found below:

  • The upper limit on method references and string references without jumbo dex is 65536.
  • A method reference is a unique name by which a method is defined and/or invoked, and is only counted once. That is to say:
    • if you call an externally defined method (e.g.. something in the core Java runtime) once, that’s one reference
    • if you call it again, it’s still only one reference
    • If you define a method, that’s one reference
    • If you call the same method, it’s still only one reference
  • A string reference is any unique string literal. Note this includes strings defined in resources that become literals in R.
  • Jumbo dex doesn’t seem to have an effect via project.properties (or perhaps both Jon and I are doing it wrong), but it does appear to work in both local and server builds
  • With jumbo dex on, the string reference limit is somewhere between 110K and 120K.
  • With jumbo dex on, the method reference limit is still 65536 (confirmed!!)
SamWise
  • 698
  • 10
  • 16
  • For the sake of completeness, there actually used to be jumbo variants of invoke opcodes at some point (no clue if they worked though), but they [were later removed](https://groups.google.com/d/msg/android-contrib/xU-hBKsiKtk/4R5Xh8dXJ3IJ). If you look into the [bytecode listing](http://source.android.com/devices/tech/dalvik/dalvik-bytecode.html), you'll see that method references are 16-bit (thus up to 65535). – teprrr Jul 31 '14 at 05:44
  • With the newest Android Studio and Gradle builds this is moot. Google has finally fixed it... – SamWise Jan 22 '15 at 01:57