Home / Companies / Contentful / Blog / Post Details
Content Deep Dive

Android MultiDex: Solutions to the 64K methods limit

Blog post from Contentful

Post Details
Company
Date Published
Author
Tom Reznik
Word Count
1,307
Company Posts That Month
1
Language
English
Hacker News Points
-
Post removed?
No
Summary

The 64K method reference limit in Android is imposed by the current set of Dalvik instructions, specifically invoke-* methods that expect a 16-bit argument for the target method's reference index, limiting valid values to between 0 and 65536. This can be reached by including popular third-party libraries such as Google Play Services, Guava, AppCompat V7, Android Support V4, Jackson, Joda-Time, Apache Commons Lang3, Apache Commons IO, Gson, and others. To avoid this limit, developers can use ProGuard to strip out unnecessary class references or load secondary dex files at runtime using the DexClassLoader. Alternatively, MultiDex allows splitting classes into multiple dex files, enabling a 64K method reference limit without exceeding it. By adding the --multi-dex flag to the build.gradle file and utilizing the Android Support Library's MultiDex support, developers can overcome the 64K method reference limit. ProGuard can also be used to shrink, optimize, and obfuscate code by removing unused code and renaming classes, fields, and methods with semantically obscure names.

Trends Found in this Post
Trend Post Mentions Total Month Mentions Posts Companies MoM
Developer Experience 3 4 2 2 -
Use This Data

Use this post, company, and trend context to find content marketing opportunities, perform competitive analysis, or address product feature gaps via the Plushcap MCP server or the Plushcap API.