Tool
dx has the following options:
- - minimum-main-dex - will only place the classes selected in the main-dex-list in the main dex file.
- - set-max-idx-number - an undocumented option that determines the maximum number of methods for a single dex file.
You must customize your build.gradle script by specifying these two parameters. In the example ( source ):
tasks.withType(com.android.build.gradle.tasks.Dex) { dexTask -> def command = [] as List command << ' --minimal-main-dex' command << ' --set-max-idx-number=50000' dexTask.setAdditionalParameters(command) }
Please note that this will not help if your main size is too large. There are rules that determine which classes should be placed in the main dex. I wrote about them here .
Edit (1-9-2016):
Version 1.5 of the Android plugin does not allow adding additional parameters to dx, but it seems that it will be fixed in one of future versions.
source share