I could not find solution on this site. To add incremental builds to dagger2. You need to do couple of things. Keep in mind that focusing latest version should be best the way to go specially for gradle and dagger2.
Dagger version atleast 2.18
kapt "com.google.dagger:dagger-compiler:2.18"
implementation "com.google.dagger:dagger:2.18"
into gradle.properties add:
kapt.incremental.apt=true
You need java 1.8
android {
compileOptions {
sourceCompatibility = '1.8'
targetCompatibility = '1.8'
}
}
kotlin version atleast 1.3.30 and latest gradle tools is better
buildscript {
dependencies {
classpath "com.android.tools.build:gradle:3.3.2"
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.3.31"
}
}
for gradle 3.3.2 in our case atleast version 4.10.1:
distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.1-all.zip
Now the most important part:
android {
defaultConfig {
javaCompileOptions {
annotationProcessorOptions {
arguments << ["dagger.gradle.incremental": "true"]
}
}
}
Enjoy.
The part in the build.gradle is no longer required, as this is now enabled by default in Dagger (since 2.24). See https://github.com/google/dagger/issues/1120
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With