Faster Incremental Builds

Thanks. Hopefully I configured it correctly, but I got a “is not incremental, Unable to infer the source directories.” error.

:app:compileDebugJava
Executing task ':app:compileDebugJava' (up-to-date check took 0.02 secs) due to:
  Input file /AndroidStudioProjects/CompileJavaTest/app/src/main/java/compilejavatest/E.java has changed.
:app:compileDebugJava - is not incremental. Unable to infer the source directories.
Compiling with JDK Java compiler API.
Class dependency analysis for incremental compilation took 0.031 secs.
Created jar classpath snapshot for incremental compilation in 0.032 secs.
Written jar classpath snapshot for incremental compilation in 0.005 secs.
:app:compileDebugJava (Thread[main,5,main]) completed. Took 1.664 secs.

And this is my configuration in build.gradle:

afterEvaluate {
    android.applicationVariants.each { variant ->
        variant.javaCompile.options.incremental = true
    }
}