Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
"64k out to be enough for anyone"
Search
Michael Evans
October 29, 2014
Technology
2k
1
Share
"64k out to be enough for anyone"
64k method limit talk @ DC Droids meetup
Michael Evans
October 29, 2014
More Decks by Michael Evans
See All by Michael Evans
#AndroidBuilds at Twitter
michaelevans
0
45
Android U+2764 (❤) Emoji
michaelevans
4
770
Kotlin for Android Developers - DevFest Chicago / DC
michaelevans
1
270
@AnnotationProcessors("ByExample") (Droidcon NYC 2015)
michaelevans
24
22k
Other Decks in Technology
See All in Technology
Dynamic Workersについて
yusukebe
2
480
A Harness for Behaviour: how to get AI to generate code that does what we intend, or "TDD in the age of AI"
xpmatteo
1
520
ビジュアルプログラミングIoTLT vol.23
1ftseabass
PRO
0
160
Claude Codeですべての日常業務を爆速化しよう!
minorun365
PRO
16
16k
大規模災害時でも高い信頼性を維持するアプリケーション基盤の実現/nikkei-tech-talk46
nikkei_engineer_recruiting
0
120
Java正規表現エンジン(NFA)の仕組みと パフォーマンスを維持するための最適化手法
takeuchi_132917
0
150
イベントストーミングとKiroの仕様駆動開発で実現する要件の認識合わせプロセス
syobochim
7
970
テストコードのないプロジェクトにテストを根付かせる
tttol
0
230
Agentic AI時代における メルカリのAIガバナンスとガードレール実装
naoichihara
16
17k
AI時代から振り返るTerraform drift運用の歴史 / AI Age Reflections on the History of Terraform Drift Operations
aeonpeople
0
600
Anthropic AIネイティブ・スタートアップ構築のプレイブック を理解する
nagatsu
0
220
インフラが苦手でも大丈夫! 紙芝居 Kubernetes -WWGT 10周年編-
aoi1
1
310
Featured
See All Featured
Impact Scores and Hybrid Strategies: The future of link building
tamaranovitovic
0
290
How to Build an AI Search Optimization Roadmap - Criteria and Steps to Take #SEOIRL
aleyda
1
2.1k
Tell your own story through comics
letsgokoyo
1
930
How Software Deployment tools have changed in the past 20 years
geshan
0
34k
16th Malabo Montpellier Forum Presentation
akademiya2063
PRO
0
130
Product Roadmaps are Hard
iamctodd
PRO
55
12k
Rebuilding a faster, lazier Slack
samanthasiow
85
9.5k
The Curse of the Amulet
leimatthew05
1
13k
Self-Hosted WebAssembly Runtime for Runtime-Neutral Checkpoint/Restore in Edge–Cloud Continuum
chikuwait
0
550
The Success of Rails: Ensuring Growth for the Next 100 Years
eileencodes
47
8.1k
Building Experiences: Design Systems, User Experience, and Full Site Editing
marktimemedia
0
520
Information Architects: The Missing Link in Design Systems
soysaucechin
0
940
Transcript
Mike Evans LivingSocial @m_evans10
“640K ought to be enough for anybody.”
–Dalvik Developers “64K ought to be enough for anybody.”
Dalvik?
Dalvik?
Dalvik The VM that runs Android. Optimized for mobile devices.
Java/Scala/Clojure/etc Compiler (.jar) .class files JAVA ARCHITECTURE
.class files classes.dex Java/Scala/Clojure/etc Compiler dex (.apk) ANDROID ARCHITECTURE
Java/Scala/Clojure/etc Compiler dex optimizer (odex) zipalign proguard ANDROID ARCHITECTURE classes.dex
(.apk) .class files
Okay…what’s the problem?
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:
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; …
So what can we do?
SOLUTION #0:
ART? SOLUTION #1:
SOLUTION #2: Proguard Java class file shrinker, optimizer and obfuscator
! Detects and removes unused classes, fields, methods and attributes
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
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
MultiDexApplication BRAND NEW
MultiDexApplication Native in Lollipop ! Part of support library (all
the way to Donut!) ! Not supported officially in developer tools…yet BRAND NEW
an egregious hack
a clever solution an egregious hack
None
$ ./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
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:
$ 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:
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: {
GAMES DRIVE ADS CAST
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
$ ./dex-method-counts LivingSocial.apk ! Read in 40364 method IDs. <root>:
40364 : 3 android: 6837 accessibilityservice: 6 bluetooth: 2 …
Questions?