My application has a bunch of librarys that are essential that is why I was forced to use multidex support library and it works nicely. But where the problem shows is in the gradle buid speed. It takes on average 2minutes to build and when I am developing and testing this is quite annoying.
Is there a way to speed up my debug builds?
You can speed-up your development builds by specifying the minimum SDK version = 21.
Official documentation includes a whole section about that.
Example (from documentation):
Once you added the product flavors, you can use the
devDebug
task (instead of defaultdebug
task) for your development builds:- from command line: run
./gradlew installDevDebug
- from Android Studio: open Build Variants window and select the
devDebug
build variant.You should, of course, work against a device whose SDK >= 21.
There's also a solution for those who don't want to use flavors. As suggested in this gist, dynamically calculate the
minSdkVersion
value:In this example, we're checking if
devMinSdk
property defined, and if true - we're using it. Otherwise, we default to 14.How do we pass
devMinSdk
value to build script? Two options:Using command line:
Using Android Studio preferences:
Go to Preferences (Settings on Windows) -> Build, Execution, Deployment -> Compiler -> put
-PdevMinSdk=21
in Command-line Options text box.