Skip to content

Gradle fast compile

Marcos Trujillo edited this page Mar 27, 2015 · 6 revisions

How To

Fast compile with multidex gradle projects

  • Add android:vmSafeMode="true" to your debug AndroidManifest.xml
<application
        android:name=".MyApp"
        android:hardwareAccelerated="true"
        android:vmSafeMode="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"/>

Remember, in your yourProject/yourModule/src/debug directory

  • Update compileSdkVersion and builToolsVersion to, at least, API 22:
    compileSdkVersion 22
    buildToolsVersion '22.0.1'
  • You need minSdkVerion to be at least API 21 to experience building time improvements. We will cover how to make this dynamic depending on BuildType later on. For the moment hardcode it to check if it actually works for you.
    defaultConfig {
        minSdkVersion 21
    }
  • Disable incremental and preDexLibraries flags
    dexOptions {
        incremental = false
        preDexLibraries = false
        
    }
  • Extra suggestion: Use at least the version 1.2 RC 4 of Android Studio(canary channel). In this version (and in the RC 3). Google merge the Intellij 14 version that include a huge improvement in the gradle compilation time. Make this under your responsibility, it isn't a final version)
Clone this wiki locally