Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add incremental builds to Dagger 2

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.

like image 893
Kebab Krabby Avatar asked Nov 07 '22 16:11

Kebab Krabby


1 Answers

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

like image 79
bairprogramming Avatar answered Nov 15 '22 08:11

bairprogramming