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
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
"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
47
Android U+2764 (❤) Emoji
michaelevans
4
780
Kotlin for Android Developers - DevFest Chicago / DC
michaelevans
1
280
@AnnotationProcessors("ByExample") (Droidcon NYC 2015)
michaelevans
24
22k
Other Decks in Technology
See All in Technology
小さくはじめるSLI/SLO ~育てながら組織に定着させる実践知~ / Starting Small with SLI/SLOs: Building Adoption Through Continuous Growth
nari_ex
4
1.6k
社内 AI エージェント Synapse と セマンティックレイヤーの育て方
hiroakis
2
1.6k
2026 TECHFRESH 畢業分享會 - AI-Native 重塑軟體工程與虛擬講師
line_developers_tw
PRO
0
760
FinOps × AIエージェントで実現する コストインシデントの自動調査
oasis1994liveforever
0
120
Kubernetesにおける学習基盤とLLMOpsの概要
ry
1
240
AIの性能が向上しても未解決な組織の重大問題は何か?/An Unsolved Organizational Problem in the Age of AI
moriyuya
3
610
ポケモンの型をTypeScriptの型システムで表現してみた
subroh0508
0
370
Oracle AI Database@Azure:サービス概要のご紹介
oracle4engineer
PRO
6
1.9k
白金鉱業Meetup_Vol.24_「AIエージェントは分けるほど良い」は本当か? / Is it true that “the more you divide AI agents, the better”?
brainpadpr
1
290
脆弱性対応、どこで線を引くか
rymiyamoto
0
360
AmazonRoute 53ではじめてのドメイン取得!HTTPS化までの道のりを整理してみた
usanchuu
3
130
Android の公式 Skill / Android skills
yanzm
0
120
Featured
See All Featured
Practical Tips for Bootstrapping Information Extraction Pipelines
honnibal
25
2k
How To Stay Up To Date on Web Technology
chriscoyier
790
250k
"I'm Feeling Lucky" - Building Great Search Experiences for Today's Users (#IAC19)
danielanewman
231
23k
A Modern Web Designer's Workflow
chriscoyier
698
190k
svc-hook: hooking system calls on ARM64 by binary rewriting
retrage
2
290
What's in a price? How to price your products and services
michaelherold
247
13k
Designing for humans not robots
tammielis
254
26k
4 Signs Your Business is Dying
shpigford
187
22k
No one is an island. Learnings from fostering a developers community.
thoeni
21
3.7k
Java REST API Framework Comparison - PWX 2021
mraible
34
9.3k
Darren the Foodie - Storyboard
khoart
PRO
3
3.4k
AI Search: Where Are We & What Can We Do About It?
aleyda
0
7.6k
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?