I have an Android project with several modules where the build time is slow, even if I try to rebuild it without changing anything.
Its structure is similar to:

There are more โparentalโ (and independent parental siblings) and โfunctionalโ modules, but settings are image settings.
My gradle.properties file is as follows:
org.gradle.jvmargs=-Xmx4096m -Xms2048m org.gradle.parallel=true org.gradle.daemon=true org.gradle.configureondemand=true
And I use Gradle version 3.5 and plugin version 2.4.0-alpha7.
The project also uses multidex ( javaMaxHeapSize "4g" and jumboMode true ), data binding, kotlin along with java, and several annotation processors.
When building, I see several threads that perform different tasks in parallel for most of the project, except, mainly, for the final "app" module (which, I believe, is normal).
But a lot of time seems to be spent on different :: compileJavaWithJavac tasks. Without even changing anything, the assembly takes about 30 seconds on a MacBook Pro i7 with 16 GB of RAM.
If I change one line of code inside a function module method (without even changing the method signature), the build time will exceed 1:30 minutes.
Are these ordinary times? Is there something I can optimize to improve build time?
I also checked some other answers:
- From this setting
preDexLibraries = false does not help, and I already use assembleDebug incremental = true suggested here does not work and deprecated- Disabling instant start seems to help a little, but not much
- The project build option already described above sets
minSdkVersion 21