It\'s easy to enable multi-dex option for gradle build system, but I haven\'t found example how I can enable this option for ant building. How can archive this?
I introduced multi-dex support in application using ant based on Ruboto's build.xml (kudos to them!). So that's the path I would recommend to take. In that case you don't have to create custom ant jars, just edit your build.xml and apply all non-gradle steps from https://developer.android.com/tools/building/multidex.html
As for build.xml you would have to take a look if all paths play well with each other, you might have changed some of them and need to adjust ant steps.
In my case I had to also generate list of classes that must be placed in first generated dex (default one), so the app could even start as it loads additional dexes in Application's onCreate. In order to do that you need to run script mainDexClasses, which you will find in your build-tools:
mainDexClasses [--output
Alex Lipov wrote nice post about it.
When you have list of classes generated, you have to point to this list in dx's parameter by adding
where dx is executed.
It's worth remembering that Ruboto's script assumes that only one additional dex will be created, which is not always case. I had two additional dexes generated so I implemented adding if exists:
And multidex support in Ant is on! It's not as easy as with gradle, but it's possible.
UPDATE: my build.xml (apart from not answer-related parts):
Adding classes2.dex to ${resource.package.file.name}
Adding classes3.dex to ${resource.package.file.name}
Converting compiled files and external libraries into ${out.absolute.dir} (multi-dex)
Dexing ${out.classes.absolute.dir} and ${toString:out.dex.jar.input.ref}