As stated in various articles (example: Jetbrains blog) and official documentation, in order to speed up android app builds it is recommended to enable compile avoidance. In order to do so the following parameters have to be added to gradle.properties:
# positive value will enable caching
# use the same value as the number of modules that use kapt
kapt.classloaders.cache.size=5
# disable for caching to work
kapt.include.compile.classpath=false
And that is what I did. But if both of these parameters are in gradle.properties, then one of the modules with databinding randomly fails to compile stating that DataBindingImpl classes are missing. If I remove at least one of mentioned parameters - everything compiles without any issues.
Since I am cleaning all of the project and then rebuilding it - compile avoidance should be skipped, because theoretically all of the file contents are changed.
Is there something with databinding and compilation avoidance that is incompatible? I can't seem to find any information about this. Why with these flags DataBindingImpl classes stop generating?
Entire gradle.properties content:
org.gradle.jvmargs=-Xmx2048m -XX:+UseParallelGC -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
org.gradle.parallel=true
android.useAndroidX=true
android.enableJetifier=true
org.gradle.daemon=true
org.gradle.caching=true
kapt.incremental.apt=true
kapt.classloaders.cache.size=8
kapt.include.compile.classpath=false
You can add the following code in gradle.properties file to avoid getting errors for data binding
kapt.classloaders.cache.disableForProcessors=android.databinding.annotationprocessor.ProcessDataBinding