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
17
Android U+2764 (❤) Emoji
michaelevans
4
500
Kotlin for Android Developers - DevFest Chicago / DC
michaelevans
1
170
@AnnotationProcessors("ByExample") (Droidcon NYC 2015)
michaelevans
24
21k
Other Decks in Technology
See All in Technology
権威ドキュメントで振り返る2024 #年忘れセキュリティ2024
hirotomotaguchi
2
730
多領域インシデントマネジメントへの挑戦:ハードウェアとソフトウェアの融合が生む課題/Challenge to multidisciplinary incident management: Issues created by the fusion of hardware and software
bitkey
PRO
2
100
Storage Browser for Amazon S3
miu_crescent
1
140
20241220_S3 tablesの使い方を検証してみた
handy
3
360
社外コミュニティで学び社内に活かす共に学ぶプロジェクトの実践/backlogworld2024
nishiuma
0
260
NilAway による静的解析で「10 億ドル」を節約する #kyotogo / Kyoto Go 56th
ytaka23
3
370
OpenAIの蒸留機能(Model Distillation)を使用して運用中のLLMのコストを削減する取り組み
pharma_x_tech
4
550
2024年にチャレンジしたことを振り返るぞ
mitchan
0
130
watsonx.ai Dojo #5 ファインチューニングとInstructLAB
oniak3ibm
PRO
0
160
Oracle Cloud Infrastructure:2024年12月度サービス・アップデート
oracle4engineer
PRO
0
170
マルチプロダクト開発の現場でAWS Security Hubを1年以上運用して得た教訓
muziyoshiz
2
2.2k
Fanstaの1年を大解剖! 一人SREはどこまでできるのか!?
syossan27
2
160
Featured
See All Featured
"I'm Feeling Lucky" - Building Great Search Experiences for Today's Users (#IAC19)
danielanewman
226
22k
What's in a price? How to price your products and services
michaelherold
243
12k
The Psychology of Web Performance [Beyond Tellerrand 2023]
tammyeverts
45
2.2k
Distributed Sagas: A Protocol for Coordinating Microservices
caitiem20
330
21k
Cheating the UX When There Is Nothing More to Optimize - PixelPioneers
stephaniewalter
280
13k
Build The Right Thing And Hit Your Dates
maggiecrowley
33
2.4k
Helping Users Find Their Own Way: Creating Modern Search Experiences
danielanewman
29
2.3k
The World Runs on Bad Software
bkeepers
PRO
65
11k
Sharpening the Axe: The Primacy of Toolmaking
bcantrill
38
1.9k
Fight the Zombie Pattern Library - RWD Summit 2016
marcelosomers
232
17k
Code Reviewing Like a Champion
maltzj
520
39k
Building an army of robots
kneath
302
44k
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?