Upgrade to Pro — share decks privately, control downloads, hide ads and more …

"64k out to be enough for anyone"

"64k out to be enough for anyone"

64k method limit talk @ DC Droids meetup

Michael Evans

October 29, 2014
Tweet

More Decks by Michael Evans

Other Decks in Technology

Transcript

  1. 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:
  2. 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; …
  3. SOLUTION #2: Proguard Java class file shrinker, optimizer and obfuscator

    ! Detects and removes unused classes, fields, methods and attributes
  4. 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
  5. 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
  6. MultiDexApplication Native in Lollipop ! Part of support library (all

    the way to Donut!) ! Not supported officially in developer tools…yet BRAND NEW
  7. $ ./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
  8. 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:
  9. $ 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:
  10. 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: {
  11. 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
  12. $ ./dex-method-counts LivingSocial.apk ! Read in 40364 method IDs. <root>:

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