gradle build fails with aapt version / timeout error
<p>I'm using gradle 2.9, Android SDK 24.4.1, and Build tools 23.0.2 on 64-bit windows 7. I updated gradle build script to support multidex (per <a href="https://stackoverflow.com/questions/26609734/how-to-enable-multidexing-with-the-new-android-multidex-support-library">How to enable multidexing with the new Android Multidex support library</a>) but I encounter this build error </p>

<pre><code>Exception in thread "stderr" java.lang.RuntimeException: Invalid aapt version, version 21 or above is required
    at com.android.builder.png.AaptProcess$ProcessOutputFacade.err(AaptProcess.java:217)
    at com.android.utils.GrabProcessOutput$1.run(GrabProcessOutput.java:102)
</code></pre>

<p>(repeats itself more than 10 times), and then</p>

<pre><code>Exception in thread "png-cruncher_1" java.lang.RuntimeException: Timed out while waiting for slave aapt process, try setting environment variable SLAVE_AAPT_TIMEOUT to a value bigger than 5 seconds
    at com.android.builder.png.AaptProcess.waitForReady(AaptProcess.java:104)
    at com.android.builder.png.QueuedCruncher$1.creation(QueuedCruncher.java:107)
    at com.android.builder.tasks.WorkQueue.run(WorkQueue.java:206)
    at java.lang.Thread.run(Thread.java:745)
</code></pre>

<p>(repeats itself more than 10 times with different values of png-cruncher_X (x = 1 to 20))</p>

<p>and the build hangs. I found similar reports (regarding the timeout part) where it was fixed by getting latest versions of certain libraries (<a href="https://stackoverflow.com/questions/30111443/android-studio-fails-to-build-new-project-timed-out-while-wating-for-slave-aapt">Android Studio fails to build new project, timed out while wating for slave aapt process</a> ) but I'm on windows and I think I've latest Android SDK &amp; build-tools. Anyone knows how to fix this? Thanks.</p>