"64k out to be enough for anyone"

48fd642048ccd225ddaffcada7a6d407?s=47 Michael Evans
October 29, 2014

"64k out to be enough for anyone"

64k method limit talk @ DC Droids meetup

48fd642048ccd225ddaffcada7a6d407?s=128

Michael Evans

October 29, 2014
Tweet

Transcript

  1. 4.
  2. 5.
  3. 11.

    Unable to execute dex: method ID not in [0, 0xffff]:

    65536 ! Conversion to Dalvik format failed: Unable to execute dex: method ID not in [0, 0xffff]: 65536 PROBLEM:
  4. 12.

    https://source.android.com/devices/tech/dalvik/dex-format.html public final class IndexMap { … public final short[]

    typeIds; public final short[] protoIds; public final short[] fieldIds; public final short[] methodIds; …
  5. 16.

    SOLUTION #2: Proguard Java class file shrinker, optimizer and obfuscator

    ! Detects and removes unused classes, fields, methods and attributes
  6. 17.

    SOLUTION #3: Refactor code so that code can be isolated

    into 2nd dex Modify classpath during runtime Allow access to methods via reflection ! Facebook did this in 2011 Secondary DEX file
  7. 18.

    SOLUTION #3: Secondary DEX file Refactor code so that code

    can be isolated into 2nd dex Modify classpath during runtime Allow access to methods via reflection ! Facebook did this in 2011
  8. 20.

    MultiDexApplication Native in Lollipop ! Part of support library (all

    the way to Donut!) ! Not supported officially in developer tools…yet BRAND NEW
  9. 23.
  10. 24.

    $ ./dex-method-counts LivingSocial.apk ! Read in 65490 method IDs. <root>:

    65490 : 3 android: 6837 accessibilityservice: 6 bluetooth: 2 … https://github.com/mihaip/dex-method-counts
  11. 25.

    GPS: 14K methods - collections, caching, primitives support, concurrency libraries,

    common annotations, string processing, I/O, and so forth. 23k methods - Basically all of Google’s services. You’ll have a hard time making a compelling app that lives in the Google Play ecosystem without it. GUAVA:
  12. 26.

    $ gradle app:dependencies —configuration “compile” ! compile - Classpath for

    compiling the main sources. +--- com.squareup.picasso:picasso:2.3.3 +--- com.jakewharton:butterknife:5.1.2 +--- com.squareup.retrofit:retrofit:1.6.1 | \--- com.google.code.gson:gson:2.2.4 -> 2.3 \--- de.hdodenhof:circleimageview:1.2.0 … ! BUILD SUCCESSFUL GUAVA:
  13. 27.

    ads analytics cast auth drive games push location maps wallet

    wearable … A clever way for Google to provide support for its many services APIs, all the way back to Gingerbread Google Play Services: {
  14. 29.

    https://gist.github.com/MichaelEvans/71150c93577de6f5ab0a Custom Gradle Task - After compilation of .class files

    Unzip the original google-play-services rm [plus|games|drive|cast] re-zip a new jar Inject new jar into dependency tree ??? Profit
  15. 30.

    $ ./dex-method-counts LivingSocial.apk ! Read in 40364 method IDs. <root>:

    40364 : 3 android: 6837 accessibilityservice: 6 bluetooth: 2 …