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
1
2k
"64k out to be enough for anyone"
64k method limit talk @ DC Droids meetup
Michael Evans
October 29, 2014
Tweet
Share
More Decks by Michael Evans
See All by Michael Evans
#AndroidBuilds at Twitter
michaelevans
0
26
Android U+2764 (❤) Emoji
michaelevans
4
670
Kotlin for Android Developers - DevFest Chicago / DC
michaelevans
1
220
@AnnotationProcessors("ByExample") (Droidcon NYC 2015)
michaelevans
24
21k
Other Decks in Technology
See All in Technology
パフォーマンスチューニングのために普段からできること/Performance Tuning: Daily Practices
fujiwara3
2
180
AI連携の新常識! 話題のMCPをはじめて学ぶ!
makoakiba
0
170
オブザーバビリティと育てた ID管理・認証認可基盤の歩み / The Journey of an ID Management, Authentication, and Authorization Platform Nurtured with Observability
kaminashi
2
1.5k
プロファイルとAIエージェントによる効率的なデバッグ / Effective debugging with profiler and AI assistant
ymotongpoo
1
640
触れるけど壊れないWordPressの作り方
masakawai
0
580
IBC 2025 動画技術関連レポート / IBC 2025 Report
cyberagentdevelopers
PRO
2
230
DMMの検索システムをSolrからElasticCloudに移行した話
hmaa_ryo
0
320
SREのキャリアから経営に近づく - Enterprise Risk Managementを基に -
shonansurvivors
1
600
251029 JAWS-UG AI/ML 退屈なことはQDevにやらせよう
otakensh
0
120
様々なファイルシステム
sat
PRO
0
280
サブドメインテイクオーバー事例紹介と対策について
mikit
1
180
AIを使ってテストを楽にする
kworkdev
PRO
0
380
Featured
See All Featured
Embracing the Ebb and Flow
colly
88
4.9k
Building an army of robots
kneath
306
46k
Unsuck your backbone
ammeep
671
58k
The Cult of Friendly URLs
andyhume
79
6.6k
RailsConf 2023
tenderlove
30
1.3k
Chrome DevTools: State of the Union 2024 - Debugging React & Beyond
addyosmani
9
940
XXLCSS - How to scale CSS and keep your sanity
sugarenia
249
1.3M
A better future with KSS
kneath
239
18k
10 Git Anti Patterns You Should be Aware of
lemiorhan
PRO
658
61k
Raft: Consensus for Rubyists
vanstee
140
7.2k
Reflections from 52 weeks, 52 projects
jeffersonlam
355
21k
個人開発の失敗を避けるイケてる考え方 / tips for indie hackers
panda_program
116
20k
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?