Our app is about 100k methods. We have no issues getting the application built using multidex (we are using gradle, latest build tools, multiDexEnabled true
and preDexLibraries false
.
We're publishing to the Amazon App Store, and in their great wisdom, they arbitrarily inject about 2000 methods after uploading. We've been contacted by them, to tell us that we should shrink down our primary classes.dex file, and move more into the secondary dex files.
I'm at a bit of a loss as to how we can so finely control what goes where.
I'm watching the build process, and am seeing build/intermediates/multi-dex/[flavor]/maindexlist.txt
. This appears to be a list of files to keep in the main dex file. It's not that large, has about 500 entries.
I'm also seeing the same directory, components.flags
. Which is an auto-generated ProGuard config to shrink down to this. After that's run, it outputs into (same directory still) componentClasses.jar
.
This componentClasses jar looks just right. It has a fairly minimal (around 10% of the total) set of classes, that are the ones absolutely required to be in the main dex file.
But when it reaches the dex step, it still packs as much as it possibly can into the primary classes.dex. No matter what we add/remove/tune, it always packs just under the absolute limit (65536) methods into there. Then spills over the remains into classes2.dex.
In order to guarantee there is scope for Amazon to inject their 2000 methods into the primary dex file, I want to ensure that only the classes that are absolutely required to be in that primary dex file, are.
How do I go about doing that?