I finally found a solution for this! It's a bit of a hack, but it works.
First, go to your ANDROID-SDK/platform-tools directory, then rename dx
app to something else, like dextool
, and finally create new dx
file with contents:
#!/bin/sh
shift
dextool --dex --incremental --no-optimize $@
Replace "dextool" with the name you chose before. This will prepend (undocumented) --incremental attribute to every dex invocation, which will massively decrease build times by dexing only classes that have changed between builds. Now it looks like this:
[dx] Merged dex A (1 defs/11,3KiB) with dex B (359 defs/1253,2KiB). Result is 359 defs/1519,3KiB. Took 0,5s
0.5s instead of 20s is a huge difference!
Edit - few remarks:
- you have to compile your project at least once before using this, because it uses previous classes.dex file
- you can run into problems when using other Android toolchains than ant
UPDATE:
Google released SDK Tools 21.0, which renders above tweak absolete, because it does supports pre-dexing. Finally!
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…