Meet "is not incremental" , when use java compile incremental feature in Android Project

I got logs like :
"is not incremental (e.g. outputs have changed, no previous execution, etc.).“
or
"is not incremental. Unable to infer the source directories.”

I just do this:
tasks.withType(JavaCompile) { task ->
task.options.useDepend = true
task.options.incremental = true
}

plus. DataBinding is also being used in my Android project.

Looks like your task does not declare the inputs and outputs - in that case, Gradle has no way of checking the timestamps and hashes, so it assumes it needs to rebuild.

https://docs.gradle.org/current/userguide/more_about_tasks.html#sec:task_inputs_outputs

But the type of the task is actually JavaCompile. You mean that I need do sth further to declare the inputs and outputs?

In that case you don’t provide enough information to answer your question. JavaCompile is surely incremental.

Incremental is a incubating feature. What information do you need to figure it out?

Incremental is a incubating feature.

Incubating or not, incremental compiling works for me and pretty much everybody except you. There is a good chance you are using it wrong.

What information do you need to figure it out?

Dunno, let me think… how about a runnable example that displays the behaviour you see?